This is a Github mirror of this codeberg repo.
This repository is read-only. Please use the above repository for forking, contributing and opening issues.
The original README is attached below for reference purposes. It may be outdated and not reflect the current README.
pnpm i @3xpo/events
import EventEmitter from '@3xpo/events';
const emitter = new EventEmitter<{
event1: (arg1: string, arg2: number) => void;
event2: (arg1: string) => void;
}>();
emitter.on('event1', (arg1, arg2) => {
console.log(arg1, arg2);
});
emitter.emit('event1', 'hello', 123);
The EventEmitter is typesafe. If you want a non-typesafe eventemitter, either pass <any>
or use NodeEventEmitter.
Note that typesafety is not available in pure JS.