EventEmitter using RxJS.
$ npm install --save-dev eventemitter-rx
$ jspm install --save eventemitter-rx
TSD files are available at our stylelab-io/DefinitelyTyped fork
$ tsd install eventemitter-rx --save
$ npm run start
// import of EventEmitter
import EventEmitter from 'eventemitter-rx';
// create an instance of it
const emitter:EventEmitter = new EventEmitter();
// dispatching an event
const EVENT:string = 'myEvent';
emitter.next(EVENT);
// dispatching an event with data
const DATA: string = 'myData';
emitter.next(EVENT, DATA);
// subscribing to an event
emitter.subscribe(EVENT, () => {
console.log('handle event');
});
// subscribing to an event and handling of its data
emitter.subscribe(EVENT, (DATA) => {
console.log('event data', DATA);
});
// unsubscribing to an event
var observer:Rx.IDisposable = emitter.subscribe(EVENT, () => {
console.log('handle event');
});
observer.dispose();
Clone project:
$ git clone https://github.com/stylelab-io/event-emitter-rx.git && cd $_
Install dependencies (only once):
$ npm i
Run tests:
$ npm test