-
Notifications
You must be signed in to change notification settings - Fork 8
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
Why does Events.off need to return the index? #199
Comments
I used |
There is some usage here: offStatic: function offStaticOverride( eventName, listener ) {
var index = Events.prototype.offStatic.call( this, eventName, listener );
// Throw an error when removing a non-listener (except when the Node has already been disposed)
if ( assert && !this.isDisposed ) {
assert && assert( index >= 0, 'Node.offStatic was called but no listener was removed' );
}
this.onEventListenerRemoved( eventName, listener );
return index;
}, |
But in that case it would be equally good to return true or false, or maybe to have Events do its own assertion. @jonathanolson what do you think? |
I'm fine with that feature being removed/changed, I don't remember using it. For Scenery, having strict error checking (fail on trying to remove a non-listener) would be nice. |
Proposed fix is here. I had to put a band-aid on one call site to prevent erroring. When I moved the error checking directly to Events.js, fuzz testing revealed a problem in many (but not all sims) that involved removing listeners from |
Events was deleted in phetsims/scenery#490, closing. |
@samreid And I couldn't find any usages of the return value from
off
oroffStatic
. I think it would be good to double check with @jonathanolson before getting rid of it though.The text was updated successfully, but these errors were encountered: