1.0.12 • Published 5 years ago

eventcb v1.0.12

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

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');

ReactJS EXAMPLE

TRIGGER FROM COMPONENT A

import Events from 'eventcb';

<button onClick={()=> Events.trigger('MYDATA-CHANGED') }>Modify</button>
<button onClick={()=> Events.trigger('MYDATA-DELETED') }>Delete</button>

RECEIVED AT COMPONENT B

import Events from 'eventcb';

componentDidMount =()=> {
   Events.bind('MYDATA-CHANGED', this.someActionOnChange);
   Events.bind('MYDATA-DELETED', this.someCleanupOnDelete);
};

RECEIVED AT COMPONENT C

import Events from 'eventcb';

componentDidMount =()=> {
   Events.bind('DATACHANGED', this.someMoreActionOnChange);
};

REMOVE BINDING

import Events from 'eventcb';

componentWillUnmount() {
   Events.unbind('MYDATA-CHANGED');		
};

FLOW

npm.io

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago