Support stopping a watcher by calling it - #148
Conversation
This can help with disabling watchers at critical moments, for example right before they are removed. This alleviates the need for work-arounds such as installing a dummy fn property and clearing the callback property.
|
Vue also has this kind of option right? |
|
Kind of: you can stop it with returned value: https://vuejs.org/guide/essentials/watchers.html#stopping-a-watcher |
|
I could rename it 'stop' and make it a method instead that also unsets the callback and fn, so that resources could be released asap? That would make it more explicit and clear that the watcher has become useless after calling it. |
|
If it still works for you I would prefer to align with vue's design when possible, otherwise feel free to diverge |
|
I've now made it as in Vue, so you can call the watcher to stop it and clean up any resources. |
|
Looks great! |
This can help with disabling watchers at critical moments, for example right before they are removed. This alleviates the need for work-arounds such as installing a dummy fn property and clearing the callback property.