TypeScript Event Bus
EventBus written in Typescript. Events are typed!
Installation
npm install eventbus-ts
Usage
Importing EventBus and Event
;
Creating Events
Create Event(s) with the specified type, i.e, string, number, etc.
Overwrite getData() if you need to custom process your data. Ex:
Register with EventBus
Register for Events with EventBus.getDefault().register(this).
Use Subscribe Decorator
Subscribe to events using @Subscribe('EVENT_NAME') for example:
onDataEventdata: string : void
Usage Sample
Posting Events
To send events call the post() method for the Event:
EventBus.getDefault.postnew DataEvent'sync up!';EventBus.getDefault.postnew NumEvent299792458;