Comments (2)
It was definitely just for simplicity. Technically there isn't a real reason to debounce rendering at all in preact-cycle
, so it could just be made synchronous. I think my original intent with the setTimeout was to support animation (since the frame delay is done for you, you just have to call the next mutation in order to ask for another frame. If that's the only real use-case though, you're right in thinking requestAnimationFrame
would be a better fit.
Some context: Preact itself originally used setTimeout(0)
, but switched to requestAnimationFrame()
in 3.x. In 4.x it tries to use the DOM for tight async but falls back to setTimeout:
https://github.com/developit/preact/blob/master/src/util.js#L125-L137
There is also an option to turn off async altogether (options.syncComponentUpdates=true
), which might be worth honoring here too.
from preact-cycle.
Just FYI requestAnimationFrame
is not triggered if tab is not visible.
setTimeout(0)
has about 4ms delay in modern browsers (it was about 15ms in old). Also setTimeout
"slows down" in invisible tab.
Alternatives:
To read more: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
from preact-cycle.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preact-cycle.