44 Working with Future: map and flatMap
After reading this lesson, you will be able to
- Manipulate the result of an asynchronous computation using the
map
operation - Merge two nested asynchronous computations using the
flatten
method - Combine multiple asynchronous operations using the
flatMap
function
In the previous lesson, you learned the basics of expressing asynchronous computations using the type Future
. In this lesson, you’ll learn how to use the methods map
, flatten
, and flatMap
for an instance of Future
. You’ll notice that they share many commonalities with the map
, flatten
, and flatMap
methods you have mastered for other types. The map
function allows you to transform the value that an asynchronous computation produces. The flatten ...
Get Get Programming with Scala 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.