Skip to content

botorjs/event-bus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Library that core of Botorjs is a event bus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published