Skip to content
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

Merged
merged 3 commits into from
Aug 12, 2019
Merged

Enable optional 'eventName' in removeAllListeners #6

merged 3 commits into from
Aug 12, 2019

Conversation

Balou9
Copy link
Contributor

@Balou9 Balou9 commented Aug 11, 2019

I have enabled eventName to be optional. #5

@Balou9 Balou9 marked this pull request as ready for review August 11, 2019 22:19
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);
Copy link
Collaborator

@realJoshByrnes realJoshByrnes Aug 12, 2019

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.

Copy link
Contributor Author

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, []);
Copy link
Collaborator

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)

@realJoshByrnes
Copy link
Collaborator

LGTM! Thanks @Balou9

@realJoshByrnes realJoshByrnes merged commit ffcf777 into denolibs:master Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants