Part 4. Data

 

At this point, you have an architecture with objects and functions connected to one another. All that’s left is to turn the hose on and let the data flow in. As with your system of conventional PVC pipes connected to bring water to your house, your application needs to be connected to transform the input into the desired output. The complexity of connecting everything arises when you need to prepare for data that can arrive at any point in time, not only when you expect it. In other words, you don’t know when someone will turn on the water, but you need to be ready for when they do.

Chapter 8 teaches you how to tame asynchronous logic with promises and direct language syntax (async/await). Promises have the advantage of being compositional objects; you can chain two or three consecutive asynchronous calls without having to worry about falling into callback hell. As the language of the web, asynchronous execution is so common that we have built-in language syntax to create async-aware functions with similar semantics as promises.