Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
That's just an immediate, aka. microtask-queue flush. The evil version is setTimeout(() => { ... }, 2) known as mtq-flush-flush among my coursemates.
-
It has to be 2 to distinguish it from a legacy mtq flush which uses a timeout of 1 because some versions of some browsers used to inline timeouts of 0.
-
Any time you "solve" a problem - regardless of language or environment or whatever else - and as you're writing it, you're thinking: "it's just a weird timing issue", you need to stop right there and REALLY dig deeper. "Little timing things" are almost NEVER little timing things... though many problems APPEAR to be on the surface. This is a lesson I drill into the heads of my team because I've seen it SO many times and seen developers burned by it time and again.
Related Rants
setTimeout(() => {
// some temporary fix, will solve later
}, 0)
...aaaand it stayed there for eternity.
joke/meme
js