Module 12 ¡ Async 1: Callbacks and the Event Loop
When to Use Which: a Callback, a Promise or an Event, and setTimeout, setInterval or requestAnimationFrame
Free with an accountReading
Maria is planning the async parts of a delivery app. She needs a price from the server once. She needs to know every time a rider's location changes. She needs the map to redraw smoothly, and an "orders" badge to refresh every thirty seconds. She knows the tools from Lessons 01 to 03. What she does not know yet is which tool fits which job.
Checking what this lesson needs for youâĻ
What is inside When to Use Which: a Callback, a Promise or an Event, and setTimeout, setInterval or requestAnimationFrame
- One answer, one listener: a callback
- One answer, passed around: a promise
- Many answers, many listeners: an event
- Callback, promise or event: the table
- setInterval or a chain of setTimeout
- requestAnimationFrame, in the browser
- setTimeout 0 or queueMicrotask
- The flowchart