Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Fix #3425: removeAllListeners should delete array #3431

Closed
wants to merge 1 commit into from

Conversation

reid
Copy link

@reid reid commented Jun 13, 2012

When removeAllListeners is called, the listeners array is deleted to maintain compatibility with v0.6.

This request fixes issue #3425 by reverting 78dc13f. In addition to the revert, I've updated the tests to match the reverted behavior.

When removeAllListeners is called, the listeners array
is deleted to maintain compatibility with v0.6.

Reverts "events: don't delete the listeners array"

This reverts commit 78dc13f.

Conflicts:

	test/simple/test-event-emitter-remove-all-listeners.js
@TooTallNate
Copy link

See #3425 (comment) for my alternate proposal for a solution.

@reid
Copy link
Author

reid commented Jun 13, 2012

@isaacs This needs an API doc clarification, but I haven't yet come up with something that doesn't refer to EventEmitter's internals.

this._events[type] = null;
}

// does not use listeners(), so no side effect of creating _events[type]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TooTallNate The reverted behavior explicitly tries to avoid calling listeners() to avoid creating _events[type]. Is that still needed?. Regarding your proposal in #3425 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think that's overkill. I don't consider removeAllListeners() to be a hot code path enough to justify that, but others would need to weigh in on that as well.

@isaacs
Copy link

isaacs commented Jun 15, 2012

Landed, along with an alternate fix for the thing that this was fixing, and clarification in the docs. Thanks, everyone :)

@isaacs isaacs closed this Jun 15, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants