This commit is contained in:
Ilya Kantor 2019-12-27 09:20:09 +03:00
parent e14dcd3e16
commit 461ea30b8c

View file

@ -272,6 +272,10 @@ let promise = new Promise(resolve => resolve("done!"));
promise.then(alert); // done! (shows up right now)
```
Note that this is different, and more powerful than the real life "subscription list" scenario. If the singer has already released their song and then a person signs up on the subscription list, they probably won't receive that song. Subscriptions in real life must be done prior to the event.
Promises are more flexible. We can add handlers any time: if the result is already there, our handlers get it immediately.
````
Next, let's see more practical examples of how promises can help us write asynchronous code.