While developing for the web, more often than not we interface with APIs which get us data to use on our pages or allows us to send data back to servers to be saved for later. Whether we are dealing with authentication, a form, or a dataUrl from File Reader, each of these activities have something in common; we need to wait for a response or event in order to move on. In this talk we will deep dive into JavaScript promises. By better understanding promises and how they work we can help reduce bugs like race conditions, increase code readability, and improve our project’s performance. We will cover
- How to create a Promise
- Using .then() vs async / await
- How to handle waiting for multiple promises concurrently vs in sequence
- The pitfalls of promises when using them inside of loops
- Parallels with Observables and RXJS
- Turning callbacks into promises
- Error handling