Skip to content
Discussion options

You must be logged in to vote

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)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@lindi0v
Comment options

@Tao-VanJS
Comment options

@cpakken
Comment options

@Tao-VanJS
Comment options

Answer selected by Tao-VanJS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants