This commit is contained in:
Ilya Kantor 2019-08-07 17:31:14 +03:00
parent e80667391f
commit 8bd8e90488
5 changed files with 36 additions and 191 deletions

View file

@ -331,4 +331,4 @@ We can immediately see a few benefits over the callback-based pattern:
| Promises allow us to do things in the natural order. First, we run `loadScript(script)`, and `.then` we write what to do with the result. | We must have a `callback` function at our disposal when calling `loadScript(script, callback)`. In other words, we must know what to do with the result *before* `loadScript` is called. |
| We can call `.then` on a Promise as many times as we want. Each time, we're adding a new "fan", a new subscribing function, to the "subscription list". More about this in the next chapter: [](info:promise-chaining). | There can be only one callback. |
So Promises give us better code flow and flexibility. But there's more. We'll see that in the next chapters.
So promises give us better code flow and flexibility. But there's more. We'll see that in the next chapters.