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

2.8.1 • Public • Published

@xlit/event

Work with events

Installation

npm i @xlit/event

Getting started

import { MemoryEventBus, select } from '@xlit/event';

class Event1 {
  kind = 'Event1';
}

class Event2 {
  kind = 'Event2';
}

const bus = new MemoryEventBus();

bus.addHandler((evt) => {
  // handle all events
});

bus.addHandler(select('Event1', (evt: Event1) => {
  // handle only Event1 events
}));

bus.addHandler(select('Event2', (evt: Event2) => {
  // handle only Event2 events
}));

bus.dispatchEvent(new Event1());
bus.dispatchEvent(new Event2());

Package Sidebar

Install

npm i @xlit/event

Weekly Downloads

0

Version

2.8.1

License

MIT

Unpacked Size

6.64 kB

Total Files

13

Last publish

Collaborators

  • reekoheek