1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/util/anyEventEmitter.ts

15 lines
468 B
TypeScript
Raw Normal View History

import EventEmitter from 'events';
export const ANY_EVENT = '*';
// Extends the built-in EventEmitter with support for listening for any event.
// See https://stackoverflow.com/a/54431931.
export class AnyEventEmitter extends EventEmitter {
emit(type: string, ...args: any[]): boolean {
super.emit(ANY_EVENT, ...args);
return super.emit(type, ...args) || super.emit('', ...args);
}
}
2023-03-02 09:52:19 +01:00
export const sharedEventEmitter = new AnyEventEmitter();