Merge pull request #2697 from joaquinelio/patch-4

promise chain flow
This commit is contained in:
Ilya Kantor 2021-10-10 18:49:20 +03:00 committed by GitHub
commit 2e494c7b28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,7 +36,7 @@ The idea is that the result is passed through the chain of `.then` handlers.
Here the flow is: Here the flow is:
1. The initial promise resolves in 1 second `(*)`, 1. The initial promise resolves in 1 second `(*)`,
2. Then the `.then` handler is called `(**)`. 2. Then the `.then` handler is called `(**)` wich in turn creates a new promise.
3. The value that it returns is passed to the next `.then` handler `(***)` 3. The value that it returns is passed to the next `.then` handler `(***)`
4. ...and so on. 4. ...and so on.
@ -44,7 +44,7 @@ As the result is passed along the chain of handlers, we can see a sequence of `a
![](promise-then-chain.svg) ![](promise-then-chain.svg)
The whole thing works, because a call to `promise.then` returns a promise, so that we can call the next `.then` on it. The whole thing works, because every call to a `.then` returns a new promise, so that we can call the next `.then` on it.
When a handler returns a value, it becomes the result of that promise, so the next `.then` is called with it. When a handler returns a value, it becomes the result of that promise, so the next `.then` is called with it.