Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

state.unobserve(keypath) #8

Closed
Mparaiso opened this issue Aug 13, 2013 · 1 comment
Closed

state.unobserve(keypath) #8

Mparaiso opened this issue Aug 13, 2013 · 1 comment

Comments

@Mparaiso
Copy link

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
Copy link
Owner

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

Rich-Harris added a commit that referenced this issue Aug 17, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants