Repository navigation
Conversation
There was a problem hiding this comment.
Could you just do evlistener.listener || evlistener?
There was a problem hiding this comment.
Sure thing, pushing that up. This was just mirroring the check as written for 'newListener'.
|
LGTM with a couple comments. |
49951dc to
3b2551a
Compare
|
LGTM with a nit… #5564 was labelled as semver-major. What do you think? |
|
#6394 got through as a patch, so it could probably go either way. It just depends if we want to look at this as a bug or not. |
|
I call bug. |
|
LGTM if CI is green and @addaleax' nit is addressed. |
3b2551a to
d667704
Compare
|
Updated with |
|
CI: https://ci.nodejs.org/job/node-test-commit/3436/ Going to land this if it’s green. |
|
Should we run citgm against this? I don't understand whether or not there is risk here. Edit: here's a run regardless: https://ci.nodejs.org/view/Node.js-citgm/job/thealphanerd-smoker/277/ |
|
Couple of citgm failures on ubuntu ppc -> https://ci.nodejs.org/view/Node.js-citgm/job/thealphanerd-smoker/277/nodes=ppcle-ubuntu1404/tapTestReport/ |
|
Nothing that looks related… @Fishrock123 is it okay for you to consider this a semver-patch one? |
|
I don't have a firm opinion. If you are confident about it, go ahead. :) |
|
The more I think about this the more I start to get cautious… e.g. I didn’t realize this so far, but I’d be creating a bug myself in #6635 if this one landed, too, because I was assuming that re-adding the elements from So, eh, thanks for making me think twice… |
|
i.e. there’s a valid use case for the old behaviour, namely temporarily disabling listeners by storing the result of |
|
This was discussed before in #914, will break several modules, and is clearly a semver-major. See https://github.com/timoxley/overshadow-listeners/blob/master/index.js, for example. |
|
Could we add an option to |
|
I view this one as a bug fix and would rather the default behavior be to
|
|
@jasnell It looks like there will be no way to re-attach the events then, which could be useful for cloning, intercepting, or temporary disabling events. Perhaps some API should be added that allows that? Edit: obviously missed «no» here, updated. |
|
Concrete proposal for implementation as an optional feature: addaleax/node@cd0a542310be. What do you think? |
|
Could someone clarify for myself and anyone else who may drop in here what we mean by "unwrapping"? Thanks! |
|
@Fishrock123 oh, sorry, wasn’t aware that this isn’t clear here (and that also means that we probably need a better name). So, I hope the following sums up everything so far: Basically, Unwrapping refers to returning the For example, in const emitter = new EventEmitter();
function listener() {}
emitter.once('foo', listener);
emitter.listeners('foo')[0] === listener // this should be true? no?
emitter.listeners('foo')[0].listener === listener // this is currently true, but not documented in any wayit would probably reflect user expectations to return the original |
Ah right, I totally knew that but didn't link the two... >_< |
|
@nodejs/ctc ... looks like this one fell by the way side accidentally. Please take a moment to review (again if you already reviewed it once). |
|
LGTM if CI is green. |
| ret = [evlistener]; | ||
| ret = [evlistener.listener || evlistener]; | ||
| else | ||
| ret = arrayClone(evlistener, evlistener.length); |
There was a problem hiding this comment.
No, the other usages of arrayClone expect the wrapped listeners.
There was a problem hiding this comment.
I would expect declaring unwrapListeners within listeners (I believe that's what you're suggesting?) to result in a performance degradation.
|
CI is green and CITGM is only showing known flaky failures. Will get this landed. |
|
Landed in b7a8a69! (finally ;-) ...) |
Matches the Node 8 API. v1 matched Node 4, and some new methods have since been introduced (notably `prepend[Once]Listener`). The major bump in `events` was because: - There is a breaking change in the `listeners()` method regarding `once()` listeners nodejs/node#6881 I think it's super unlikely to affect anyone, but there you go. - The gzipped size almost doubled from 1.1KB to 2.1KB. It'll shrink a bit because some patches have since landed in Node that remove some code, but it'll still be bigger than it was because of the new methods. Deets: https://github.com/Gozala/events/releases/tag/v2.0.0
Checklist
Affected core subsystem(s)
events
Description of change
Fixes: #6873