@botorjs/event-bus
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Event Bus

Build Status Coverage Status

Library that core of Botorjs is a event bus

Installation

npm install @botorjs/event-bus --save

Setup 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

Package Sidebar

Install

npm i @botorjs/event-bus

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

21.8 kB

Total Files

11

Last publish

Collaborators

  • nortonperson