@xola/xolabot-sdk

2.0.1 • Public • Published

Xolabot SDK

Installation

$ npm install xolabot-sdk

Usage

import { Module } from 'xolabot-sdk';

class MyModule extends Module {
    constructor(...args) {
        super('my_module_name', ...args);

        // Register bus event listeners here...
    }
}

// Required.
// This is how module will be registered with Xolabot.
MyModule.load();

Available APIs

Event Bus (EventBus)

Event bus is available as an instance property: this.bus.

Subscribe to an event.

/**
 * @param   {Object}   event
 * @param   {string}   event.channel
 * @param   {string}   event.type
 * @param   {Function} listener
 * @returns {Function} Function for unsubscribing from the event.
 */
this.bus.on(event, listener);

Subscribe to an event once.

/**
 * @param   {Object}   event
 * @param   {string}   event.channel
 * @param   {string}   event.type
 * @param   {Function} listener
 * @returns {Function} Function for unsubscribing from the event.
 */
this.bus.once(event, listener);

Unsubscribe from an event.

/**
 * @param   {Object}   event
 * @param   {string}   event.channel
 * @param   {string}   event.type
 * @param   {Function} listener
 * @returns {Function} Function for unsubscribing from the event.
 */
this.bus.off(event, listener);

API Client (Axios)

Available as an instance property: this.api.

See official documentation.

Save State to Local Storage

/**
 * @param state {Object}
 */
this.saveState(state);

Readme

Keywords

none

Package Sidebar

Install

npm i @xola/xolabot-sdk

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

4.96 kB

Total Files

4

Last publish

Collaborators

  • ranjantanya
  • tanushreec
  • manojvaibhav
  • anushr
  • rushiv