-
-
Notifications
You must be signed in to change notification settings - Fork 159
Open
Description
As per the flow, I can see Micro task is executed before the macro task.
So the Event loop pseudocode may be:
while (EventLoop.waitForTask()) {
const microtaskQueue = EventLoop.microTaskQueue;
while (microtaskQueue.hasNextMicrotask()) {
microtaskQueue.processNextMicrotask();
}
const taskQueue = EventLoop.selectTaskQueue();
if (taskQueue.hasNextTask()) {
taskQueue.processNextTask();
}
rerender();
}
Example code:
setTimeout(function a() {console.log("Macro");}, 0);
Promise.resolve().then(function b(){console.log("Micro");});
console.log("Stack");
Output:
Stack
Micro
Macro
jackchoumine, KaerMorgan, khamroevjs and yaubara
Metadata
Metadata
Assignees
Labels
No labels