fix: Allow emit to be accessed anywhere (#3848)

This commit is contained in:
Mekhi 2024-05-24 04:14:17 +08:00 committed by GitHub
parent 32ed87b409
commit ec1752374e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,7 @@ export class EventEmitter<T extends Record<string, any>> {
return this return this
} }
protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this { public emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this {
const callbacks = this.callbacks[event] const callbacks = this.callbacks[event]
if (callbacks) { if (callbacks) {
@ -46,7 +46,7 @@ export class EventEmitter<T extends Record<string, any>> {
return this return this
} }
protected removeAllListeners(): void { public removeAllListeners(): void {
this.callbacks = {} this.callbacks = {}
} }
} }