@taikonauten/event-emitter
TypeScript icon, indicating that this package has built-in type declarations

2.3.5 • Public • Published

Taikonauten event-emitter

Event-emitter is a wrapper library to abstract access to underlying event emitter libraries. In this case EventEmitter3 is used.

The benefit of using this library is to be able to quickly replace the event emitter implementation without changing the signature of existing code.

Installation

npm install --save @taikonauten/event-emitter

Usage

import emitter from '@taikonauten/event-emitter';

const callback = (params) => {
  console.log('test-event fired with params', params);
});

// add a listener
emitter.addListener('test-event', callback);

const testData = {
    message: 'success',
    event: 'test-event',
};

// emit the event
// result: test-event fired with params {message: 'success', event: 'test-event'}
emitter.emit('test-event', testData);

// remove the listener at any time
emitter.removeListener('test-event', callback);

Made with ♡ at Taikonauten

Readme

Keywords

none

Package Sidebar

Install

npm i @taikonauten/event-emitter

Weekly Downloads

12

Version

2.3.5

License

MIT

Unpacked Size

3.89 kB

Total Files

4

Last publish

Collaborators

  • sf-taiko
  • taiko-org
  • nicolaisteinel
  • schllng
  • lempa
  • tststststststs