TooTallNate/node-weak

weak.callbacks uses EventEmitter.listeners which returns array.slice

jameshartig opened this issue · 4 comments

The documentation for weak.callbacks says:

The array can be push()ed or unshift()ed onto, to have more control over the execution order of the callbacks.

But looking at EventEmitter.prototype.listeners it seems that listeners returns a slice of the actual events array so we can't use the result of callbacks to re-order or delete callbacks.

Good point. I believe the listeners() behavior used to return the listeners array untouched, but that was changed in v0.10 to return a copy. Patch fixing the docs appreciated!

Should I make callbacks return the underlying _events array or just fix the docs? If just a docs fix is preferred, would you be opposed to adding a removeAllCallbacks method?

Maybe we should just expose a way to return the underlying EventEmitter?

On Wednesday, April 1, 2015, James Hartig notifications@github.com wrote:

Should I make callbacks return the underlying _events array or just fix
the docs? If just a docs fix is preferred, would you be opposed to adding a
removeAllCallbacks method?


Reply to this email directly or view it on GitHub
#43 (comment)
.

The only issue with that is the event name (_CB) is privately scoped. I'm making a PR let's move the discussion there. I think we're both in agreement that this issue is an issue and should be fixed someway or another.