4.2.4 • Published 9 months ago

evtm v4.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

npm browser node TypeScript

evtm

A lightweight zero-dependency event manager with flexible event type matching

Usage

Initialization:

import {EventManager} from 'evtm';

let eventManager = new EventManager();

Adding a handler of a specific event type:

eventManager.addListener('task started', event => {
    console.log(event);
});

Of all events matching the pattern:

eventManager.addListener(/^task\s/, event => {
    console.log(event);
});

With captured parameters:

eventManager.addListener(/^(\S+)\s(?<status>.*)$/, event => {
    console.log(event.params[0], event.params.status);
});

Adding a handler of all events dispatched to the eventManager instance:

let listener = eventManager.addListener('*', event => {
    console.log(event);
});

Dispatching an event of a specific type and properties:

eventManager.dispatch('task started', {x: 42});

Removing a previously declared listener:

listener.remove();
4.2.3

9 months ago

4.2.4

9 months ago

4.2.2

1 year ago

4.2.1

1 year ago

4.2.0

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago