npm.io
1.0.0 • Published 6 years ago

@gotoeasy/bus

Licence
MIT
Version
1.0.0
Deps
0
Size
6 kB
Vulns
0
Weekly
0

@gotoeasy/bus

simple event bus

NPM version License

Install

npm i @gotoeasy/bus

API

const bus = require('@gotoeasy/bus');

bus.on('input', function(txt){
    console.log('input ...', txt);
})
bus.once('once', function(txt){
    console.log('once ...', txt);
})

bus.at('input', 'abc'); // input ... abc

bus.at('once', '123'); // once ... 123
bus.at('once', '123'); // do nothing

bus.off('input');
bus.at('input', 'abc'); // do nothing

bus.clear();            // clear all events


Keywords