baseprime / grapnel

The smallest JavaScript router with named parameters, HTML5 pushState, and middleware support
http://grapnel.js.org
467 stars 40 forks source link

an `.off` method to unregister an event listener #44

Closed mhelvens closed 5 years ago

mhelvens commented 9 years ago

If your interface has an .on method to register event listeners, it really should support some way to unregister them. And to be consistent with expectations, this should be .off(event, callback).

For example, I'm trying to plug the router into a Kefir stream:

Kefir.fromEvents(this.router, 'navigate')

But the Kefir.fromEvents function will throw an error like this:

Uncaught Error: target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair
creatorrr commented 8 years ago

Progress on this, @bytecipher? Happy to submit a patch for this.