Replies: 2 comments 4 replies
-
|
we definitely need something like this to manually dispose a derive |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
You can create your own wrapper const a = van.state(1)
const customDerive = (fn) => {
let enabled = true;
van.derive(() => enabled && fn())
return () => enabled = false;
}
//log a whenever it's changed
const dispose = customDerive(() => console.log(a.val))
setInterval(() => a.val += 1, 1000)
setTimeout(dispose, 10000) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using some
van.state()andvan.derive()outside of van components. I understand that thederiveis automatically disposed when the element its called in is detached from the document (checks `isConnected()), but the derive(() => {}) called outside a van component can never be disposed?Perhaps there can be an API
Beta Was this translation helpful? Give feedback.
All reactions