3
Callbacks and Events
In synchronous programming, we think of code as a series of consecutive steps that work together to solve a specific problem. Each operation is blocking, meaning that one task must be completed before the next one can begin. This approach makes the code straightforward to read, understand, and debug.
On the other hand, asynchronous programming operates differently. Certain operations, like reading from a file or making a network request, run “in the background.” When we initiate an asynchronous operation, the next instruction executes immediately, even if the previous task hasn’t finished yet. In this context, we need a way to be notified when the asynchronous operation completes so that we can continue our execution flow ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access