Miss any of our Open RFC calls?Watch the recordings here! »

typed-ee

1.0.5 • Public • Published

TypedEventEmitter

Simple strict typed interface for EventEmitter

Installation

$ npm install --save typed-ee

Usage

After installation the only thing you need to do is require the module:

import {TypedEventEmitter} from "typed-ee/lib/TypedEventEmitter";
 
class MyEventEmitter extends TypedEventEmitter {
 
  public messageEvent = this.event<string>('message');
 
}
 
const ee = new MyEventEmitter();
 
ee.messageEvent.on((s: string) => console.log(s));
 
ee.emit('Hello world');
 
//also available once and off methods
 
ee.messageEvent.once((s: string) => console.log(s));
 
ee.messageEvent.off((s: string) => console.log(s));
 
 

http://nodejs.org/api/events.html

License

MIT

Install

npm i typed-ee

DownloadsWeekly Downloads

3

Version

1.0.5

License

ISC

Last publish

Collaborators

  • avatar