-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling optional higher precedence for 'queueMicrotask' #4891
Comments
Interesting idea, though I suspect the code of anyone who uses actually this will become quite a bit more confusing. |
Considering the fact that the Microtask API is primarily designed for libraries implementers, people who know what they're doing, I think it's an acceptable solution. |
This isn't possible, as the microtask queue is specifically a queue, so it only allows enqueuing items (at the end), not jumping the queue. Closing, but happy to continue discussing how the microtask queue works in the closed thread. |
@domenic I'd like to ask two things:
|
For understanding why queues are often used for scheduling tasks, see e.g. this Wikipedia article and the ones it links to. For understanding why we should prefer to expose primitives directly, instead of forcing people to get them indirectly through other APIs, see e.g. the extensible web manifesto. For this particular case, you may enjoy #512 or w3ctag/design-reviews#294. |
Enqueuing a callback using
queueMicrotask
:queueMicrotask(() => console.log(42))
or using
Promise.resolve()
:Promise.resolve().then(() => console.log(42))
currently has the same temporal outcome:
It is the correct behaviour, but the usefulness of the new API begins to be less relevant. Clarity apart.
I propose an enhancement, that is the possibility to enqueue a microtask not at the bottom of the microtask queue but at the top of it.
It could be easily implemented using a boolean flag, defaulted to
false
:The text was updated successfully, but these errors were encountered: