August 2018
Intermediate to advanced
380 pages
10h 2m
English
A situation where we need to run one computation after another in an asynchronous manner is a frequent pattern. One way to solve this task is via callbacks, as we have seen previously. Every asynchronous computation is a separate entity and is started from a callback that's registered on another computation it depends upon.
Another way of conceptualizing such a pattern is to treat Futures as composable entities. The concept in question is the ability to compose two Futures into one. The semantics of the combined Future is a sequential execution of the second Future after the first one.
So, given a Future for contacting the database and a Future for contacting the weather forecast server, we can create a Future that combines ...