4 ms·
How does the scheduler achieve preemption? How does it decide when to render and when to allow the event loop to run?
by millstone 7y ago
How does the scheduler achieve preemption? How does it decide when to render and when to allow the event loop to run?
- cheez 7y agoI wrote something like this many years ago and all I did was queue stuff to be processed simultaneously.
- pomber 7y agoSee https://pomb.us/build-your-own-react/#step-iii-concurrent-mode https://pomb.us/build-your-own-react/#step-iii-concurrent-mo...
- millstone 7y agoThanks. This really drives home how insane the browser architecture is. React would like to pause rendering to react to new events as they come in. However, there is no way for React to be told when there is a new event, so it has to poll for it. Unfortunately there's no way to directly poll for a new event, so it has to fake an event poll via inversion of control built on top of requestAnimationFrame.
- pomber 7y agoYes, but the React team is working together with the Chrome team to improve it. There is an `isInputPending` proposal https://techcrunch.com/2019/04/22/facebook-makes-its-first-browser-api-contribution/ https://techcrunch.com/2019/04/22/facebook-makes-its-first-b...