1.0.0 • Published 6 years ago

tiny-event-bus-js v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

EventBus

A simple EventBus tool for JavaScript

API

register(type: string)

Register a new event.

EventBus.register('demaxiya');

remove(type: string)

Remove a registered event.

EventBus.remove('demaxiya');

subscribe(type: string, cb: function)

Subscribe an event.

EventBus.subscribe('demaxiya', func);

cancel(type: string, cb: function)

Cancel subscribing an event, the 'cb' should has been added by 'subscribe'.

EventBus.cancel('demaxiya', func);

publish(type: string, data: any)

Publish en event, you can give a param 'data' to pass some data to the registered 'cb'.

EventBus.publish('demaxiya', { text: 'lalala' });