npm.io
1.0.0 • Published 4 years agoCLI

@ionaru/typed-events

Licence
MIT
Version
1.0.0
Deps
0
Size
9 kB
Vulns
0
Weekly
0
Stars
1

@ionaru/typed-events

npm version npm version Build Status

Description

A tiny package that provides a very simple event system with Typescript support.

Usage

npm install @ionaru/typed-events
import { TypedEvent } from '@ionaru/typed-events';

// Create a new event.
const myEvent = new TypedEvent<string>();

// Create a listener and subscribe to the event.
const listener = (message) => console.log(message);
myEvent.on(listener);

// Emit to notify all listeners.
myEvent.emit('Something happened!')

// console.log: 'Something happened!'