Merge pull request #2550 from hamirmahal/feat/update-readability-of-7-microtask-queue
close #2534 by slightly changing 7-microtask-queue
This commit is contained in:
commit
4b10919661
1 changed files with 2 additions and 2 deletions
|
@ -30,7 +30,7 @@ As stated in the [specification](https://tc39.github.io/ecma262/#sec-jobs-and-jo
|
|||
- The queue is first-in-first-out: tasks enqueued first are run first.
|
||||
- Execution of a task is initiated only when nothing else is running.
|
||||
|
||||
Or, to say more simply, when a promise is ready, its `.then/catch/finally` handlers are put into the queue; they are not executed yet. When the JavaScript engine becomes free from the current code, it takes a task from the queue and executes it.
|
||||
Or, to put it more simply, when a promise is ready, its `.then/catch/finally` handlers are put into the queue; they are not executed yet. When the JavaScript engine becomes free from the current code, it takes a task from the queue and executes it.
|
||||
|
||||
That's why "code finished" in the example above shows first.
|
||||
|
||||
|
@ -40,7 +40,7 @@ Promise handlers always go through this internal queue.
|
|||
|
||||
If there's a chain with multiple `.then/catch/finally`, then every one of them is executed asynchronously. That is, it first gets queued, then executed when the current code is complete and previously queued handlers are finished.
|
||||
|
||||
**What if the order matters for us? How can we make `code finished` run after `promise done`?**
|
||||
**What if the order matters for us? How can we make `code finished` appear after `promise done`?**
|
||||
|
||||
Easy, just put it into the queue with `.then`:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue