The callback pattern

Previously, we described what asynchronous and synchronous code looks like when you encounter it in your everyday life as a developer. What might be of interest is to know how an operating system looks at such code and how it deals with it. An operating system deals with asynchronous code by thinking of it in terms of the following concepts:

  • Events, these are messages that signals to the operating system that a certain type of action has occurred
  • Event handler, this is the piece of code that should run when an event has occurred
  • Event queue, this is where all events and their event handlers are placed, waiting to be executed

Let's illustrate this flow in the following diagram:

What we can see in the preceding image ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.