Содержание
- 2. Async in JS PLAN Promises Promise magic Async/Await Events & Callbacks Promise overview .then(), .catch(), parallel
- 3. ASYNC IN JS
- 4. EVENTS The most basic form of asynchronous programming in JavaScript.
- 5. CALLBACKS: BASIC Functions that are called after an asynchronous operation Usually are passed as arguments.
- 6. CALLBACKS: HARD
- 7. CALLBACKS: HELL
- 8. PROMISES
- 9. PROMISES Operation that will return its result some time later Multiple handlers of one result Complex
- 10. .THEN
- 11. PROMISES & THENABLES Promises are objects whose behaviour conforms to the Promise / A + specification
- 12. CONSTRUCTOR The function passed to new Promise() is called the executor. .then () and resolve ()
- 13. PROMISE STATES A Promise is in one of three states: pending: initial state, neither fulfilled nor
- 14. WORKING WITH PROMISES
- 15. .THEN() MAGIC .then() always returns a new promise This new promise is resolved when the previous
- 16. .THEN() & NEW PROMISE If you return a promise with .then (), it will be resolved
- 17. ERROR HANDLING Promises can be rejected with reason As a second argument, the executor receives a
- 18. RECOVERY Promises are able to "recover" If you return a value from the error handler, it
- 19. FAIL SILENTLY If an error occurs in a promise that does not have an error handler,
- 20. CREATING COMPLETED PROMISES Promise.resolve () and Promise.reject () allow you to create a completed promise They
- 21. BACK TO THENABLES Promise.resolve () and Promise.reject () can take thenable arguments They can turn thenables
- 22. PARALLEL EXECUTION: ALL Promise.all() is waits for all promises to complete Returns a new promise, which
- 23. PARALLEL EXECUTION: RACE Promise.race () creates a race among promises Returns a new promise, which completes
- 24. ASYNC/AWAIT
- 25. ASYNC/AWAIT ES7 introduced a new way to add async behaviour in JavaScript Working with promises became
- 26. SUSPEND EXECUTION await keyword suspends the asynchronous function and waits for the awaited value return a
- 27. ADD SUGAR Async/Await is just syntactic sugar for promises, so you can treat async function like
- 28. ERROR HANDLING Async/await allow us to handle errors the same way we do with synchronous code
- 30. Скачать презентацию