-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
I found the update is always slow by 1 frame when I change state in the rAF callback:
//minimal case
const a = van.state(0);
van.dervie(() => (el.textContent = a.val));
requestAnimationFrame(async (time) => {
a.val = time;
await 0; // wait next microtask
console.log(time === el.textContent); // expect true but got false
});
I know it is because the setTimeout callback will be called after the render pipeline, but updating the DOM in time in the rAF callback is usual practice.
I found that the other reactive systems usually update on the next microtask, which ensures that the update will occur before the render pipeline.
https://jsfiddle.net/akqjhcy6/
https://playground.solidjs.com/anonymous/01307c7d-763d-4d87-a00b-432f12b85936
So, is there any reason why setTimeout must be used?
Metadata
Metadata
Assignees
Labels
No labels