Skip to content

How to handle rapid events? #1686

Answered by siku2
cargillchantry asked this question in Q&A
Discussion options

You must be logged in to vote

am I right to assume this would mean the node would be destroyed and recreated for each invocation of the events?

No, Yew uses a virtual DOM approach and, where possible, only updates the existing elements with the required changes.
In your case, when a coordinate changes, Yew basically calls element.setAttribute("x", new_x_value).
This doesn't mean that you won't run into performance problems though, but you can check out the Boids example which continuously changes the position and colour of a few hundred <polygon> elements (almost) without breaking a sweat.

If you do run into performance problems at some point, you can escape from Yew's declarative world and make use of web-sys to ac…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cargillchantry
Comment options

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