Skip to content

Repository files navigation

Event Sub

A basic, and tiny but inspectable pub-sub event system.

constEvents=newEventSub();Events.subscribe('app_loaded',()=>{App.init();});Events.publish('app_loaded');

Inspection

Log events any way you want with the pluggable logger;

constEvents=newEventSub();Events.logger=(action,details)=>{// use any logger you want.console.log(action,details);};Events.subscribe('app_loaded',()=>{App.init();});
# =>SUBSCRIBE,{event: 'app_loaded'}

loggable events: [SUBSCRIBE, UNSUBSCRIBE, PUBLISH, FIRE]

Singleton

Use a singleton instance of the event system, so that all components can use the same events bus.

~event_bus.jsimport{EventSub}from'event_sub';exportvarevents=newEventSub();~everyotherfile;importeventsfrom'event_bus'events.subscribe('loaded',()=>{...});events.publish('your fancy event')

About

A basic, and tiny but inspectable pub-sub event system. (Javascript)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages