You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 24, 2017. It is now read-only.
Allows to register subscribers and dispatch events across the application.
Installation
Install module:
npm install event-dispatch --save
Use typings to install all required definition dependencies.
typings install
ES6 features are used, so you may want to install es6-shim too:
npm install es6-shim --save
if you are building nodejs app, you may want to require("es6-shim"); in your app.
or if you are building web app, you man want to add <script src="path-to-shim/es6-shim.js"> on your page.
Usage
Simply create a class and put annotations on its methods:
Then use EventDispatcher class to dispatch events:
import{EventDispatcher}from"event-dispatch";// note that all your subscribers must be imported somewhere in the app, so they are getting registered// on node you can also require the whole directory using [require all](https://www.npmjs.com/package/require-all) packageimport"./subscriber/UserEventSubscriber";leteventDispatcher=newEventDispatcher();eventDispatcher.dispatch("onUserCreate",newUser("Johny"));eventDispatcher.dispatch("onStatusUpdate","hello world");
Samples
Take a look on samples in ./sample for more
examples of usages.
Todos
cover with tests
more documentation
About
Dispatching and listening for application events in Typescript