PV247 Vilém Jeniš Asynchronous operations Vilém Jeniš JAVASCRIPT: I'm a: - single threaded - concurrent language I have - a call stack - an event loop - a callback queue - and some other APIs and stuff. JAVASCRIPT: I'm a: - single threaded - concurrent language I have - a call stack - an event loop - a callback queue - and some other APIs and stuff. JAVASCRIPT: I'm a: - single threaded - concurrent language I have - a call stack - an event loop - a callback queue - and some other APIs and stuff. JAVASCRIPT: I'm a: - single threaded - concurrent language I have - a call stack - an event loop - a callback queue - and some other APIs and stuff. Here‘s another one… JAVASCRIPT: I'm a: - single threaded - concurrent language I have - a call stack - an event loop - a callback queue - and some other APIs and stuff. Event loop Previous slides borrowed from: https://www.youtube.com/watch?v=8aGhZQkoFbQ More here: http://latentflip.com/loupe/ Question time! (Remind me if I forget…) Callback hell What is a Promise? A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred). A promise may be in one of 3 possible states: fulfilled, rejected, or pending. Promise users can attach callbacks to handle the fulfilled value or the reason for rejection. Promises are eager, meaning that a promise will start doing whatever task you give it as soon as the promise constructor is invoked. Promises as a Railway What if nothing can go wrong? How to stop an error I‘ve dealt with? Source: https://fsharpforfunandprofit.com/rop/ <- Seriously… Look at the presentation at least once! It‘s all the same.