@botorjs/event-bus
v0.0.1
Published
Library that core of Botorjs is a event bus
Maintainers
Readme
Event Bus
Library that core of Botorjs is a event bus
Installation
npm install @botorjs/event-bus --saveSetup and Example
import { EventBus } from "../src/EventBus";
var bus: EventBus = new EventBus();
//
bus.on("test", function(data) {
// process
})
bus.emit("test", "test");
// channel point-to-point
bus.registerChannel("test", "test", (data: ContextChannel) => {
// process
});
bus.emit("test","t");
bus.emit("test","t");
bus.emit("test","t");API
EventBus
| Property | Description | |---------- |:-------------| | on(name, callback) | listen event | | once(name, callback) | listen event one time | | off(name, callback) | remove listen event | | registerChannel(name, event_name, callback, limit = 0) | register a channel with callback handle | | getChannel(name) | get channel have register | | removeChannel(name) | remove channel have register |
ContextChannel
- data connext of Channel
| Property | Description | |---------- |:-------------| | data | get value data | | channel | set channel event |
Channel
| Property | Description | |---------- |:-------------| | name | name channel | | listen | listen event | | remove | remove listen event |
