-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable optional 'eventName' in removeAllListeners #6
Conversation
mod.ts
Outdated
if (this.events.has(eventName)) { | ||
const listeners = (this.events.get(eventName) as Function[]).slice(); // Create a copy; We use it AFTER it's deleted. | ||
this.events.delete(eventName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is removed. If there's no events, this.events.has(eventName) should return false
imho. I think this should be reverted, but I'm open to hear your opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ozjd You're right! I'll revert!
mod.ts
Outdated
} else { | ||
const eventList: [string | symbol] = this.eventNames(); | ||
eventList.map((value: string) => { | ||
this.events.set(value, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I think delete should be the function used here.
Additionally, this.emit("removeListener...
isn't called. It would be possible for this function to call itself on each item in the map()'s callback.
eg. this.removeAllListeners(value)
LGTM! Thanks @Balou9 |
I have enabled
eventName
to be optional. #5