eventcb
1.0.12 • Public • Published One trigger can invoke all the subscribed callbacks events
Can create any number of triggers and each trigger can have any number of event subscribers
Ultra-light code, ~400 bytes and 15 lines of code
Subscribing to the events
Events.bind('eventname', myFunction);
Triggering the subscribed events
Events.trigger('eventname');
import Events from 'eventcb';
<button onClick={()=> Events.trigger('MYDATA-CHANGED') }>Modify</button>
<button onClick={()=> Events.trigger('MYDATA-DELETED') }>Delete</button>
import Events from 'eventcb';
componentDidMount =()=> {
Events.bind('MYDATA-CHANGED', this.someActionOnChange);
Events.bind('MYDATA-DELETED', this.someCleanupOnDelete);
};
import Events from 'eventcb';
componentDidMount =()=> {
Events.bind('DATACHANGED', this.someMoreActionOnChange);
};
import Events from 'eventcb';
componentWillUnmount() {
Events.unbind('MYDATA-CHANGED');
};
Package Sidebar
Install
Weekly Downloads