subscribable-lite
v1.0.0
Published
Super Light weight Subscribe/Publish event system for Node.js and browser
Downloads
3
Readme
subscribable-lite
Super Light weight Subscribe/Publish event system for Node.js and browser. (UMD version only 395B after gzipped)
Installing
Using npm:
$ npm install subscribable-lite
Using yarn:
$ yarn add subscribable-lite
Usage
sub.subscribe(handler)
sub.publish([arg[, ...]])
import SubLite from 'subscribable-lite';
const sub = new SubLite();
sub.subscribe((a, b, c) => {
console.log(a, b, c); // => 'you are awesome'
});
sub.publish('you', 'are', 'awesome');
sub.unsubscribe([handler])
const unsubscribe = sub.subscribe((a, b, c) => {
console.log(a, b, c); // => 'will not trigger'
});
unsubscribe();
/* or `sub.unsubscribe();` */
sub.publish('you', 'are', 'awesome');
License
MIT (c) Christopher Peng (Cap32)