1.0.0 • Published 4 years ago

@perevezencev/event-emitter v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@perevezencev/event-emitter

A TypeScript library for strongly typed event emitters.

Installation

// with yarn
yarn add @perevezencev/event-emitter

// with npm
npm install @perevezencev/event-emitter

Examples

interface Events {
  request: (request: Request, response: Response) => void;
  done: void;
}

const ee = new EventEmitter<Events>();

ee.emit('request', new Request(), new Response());

ee.on('request', (req, res) => {
  // req and res are contextually typed to Request and Response
});
1.0.0

4 years ago