hookio/hook.io — Issue #161: Can't remove listener
Author: balkian
Created: 2012-02-14 11:49:16+00:00
State: open

Once an event has been added with the hook.on function using a leading wildcard, it can't be removed.
Steps to reproduce with hookio --repl:
1.- Add a callback with the "*::foo" filter:

var callback = function(){ console.log("fired")};
hook.on("*::foo",callback);

2.- Check the listeners for that filter:

hook.getEvents()['*']['foo']['_listeners']

3.- Try to remove the listener:

hook.off("*::foo",callback);

4.- See the event wasn't removed:

hook.getEvents()['*']['foo']['_listeners']

This doesn't happen if you don't use the wildcard. But this is a big problem if you're trying to change the behavior of your hook dynamically.