arqex / freezer

A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
MIT License
1.28k stars 56 forks source link

#off does not remove listener #43

Closed christianvogt closed 8 years ago

christianvogt commented 9 years ago

The check for a matching listener is incorrect. As such a listener cannot be removed.

            for (i = listeners.length - 1; i >= 0; i--) {
                if( listeners[i] === listener )
                    listeners.splice( i, 1 );
            }

The comparison should be against the callback of the listeners object.

            for (i = listeners.length - 1; i >= 0; i--) {
                if( listeners[i].callback === listener )
                    listeners.splice( i, 1 );
            }
arqex commented 8 years ago

Nice catch too! Fixed also in v0.6.1