Inspired by https://danilafe.com/blog/typescript_typesafe_events/ but using Map, Set, adding once and an async version. typed-emitter no longer works properly.
once
typed-emitter
Constructs a new event emitter.
const ev = new FreeSwitchEventEmitter<'ping',{ ping: () => console.log('ping\) }>() Copy
const ev = new FreeSwitchEventEmitter<'ping',{ ping: () => console.log('ping\) }>()
Optional
Send out an event: all registered callbacks are notified.
Register a new callback for the named event. The callback is called every time the event is emitted.
Register a new callback for the named event. The callback is only called the first time the event is emitted.
Returns a Promise that is resolved the next time the named event is emitted.
Unregisters all callbacks from the named event.
Unregister the callback from the named event.
Inspired by https://danilafe.com/blog/typescript_typesafe_events/ but using Map, Set, adding
onceand an async version.typed-emitterno longer works properly.