state.unobserve(keypath)
Mparaiso opened this issue · comments
mparaiso commented
Hi , thanks for the library.
How about state.unobserve(keypath), where keypath is a string. it should remove listeners for any keypath that matches.
for instance :
s.observe("video[0].title",aFunction);
s.observe("video[0].title",anotherFunction);
//
s.unobserve("videos[0].title");
// remove the 2 previous listeners.
Rich Harris commented
Yeah, this makes sense. Have also added an unobserveAll
method as well. By the way, you might not have picked it up from the crappy documentation (will get round to updating it one day!) but you can also cancel observers like this:
observer = state.observe( 'foo' );
observer.cancel();
Thanks for the suggestion