Skip to content

How to cleanup using van.derive()? #376

Answered by Tao-VanJS
Ashvith10 asked this question in Q&A
Discussion options

You must be logged in to vote

canvasRef is just a reference to a DOM element. In VanJS, you can achieve the same with a more straightforward way:

const canvasDom = canvas({width: 800, height: 800})

...
van.derive(() => {
  if (gameRunning.val) {
    ballManager = new BallManager(canvasDom, ...)
    ...
  } else {
    ballManager.stop()
  }
})
...

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@Tao-VanJS
Comment options

@sirenkovladd
Comment options

@Ashvith10
Comment options

@Tao-VanJS
Comment options

Answer selected by Ashvith10
@Ashvith10
Comment options

@Tao-VanJS
Comment options

@Tao-VanJS
Comment options

@Ashvith10
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants