Run Streams Concurrently and Understand Flows

Learn to run the streams concurrently using Flow.map() and understand how flows execute in code.

Run streams concurrently

We need to convert an existing data source to use Flow. The result of the conversion is called a flow. We use Flow.from_enumerable/2, to create a flow from a stream. We’ll discuss how from_enumerable/2 works in a moment.

Replace Enum with Flow

Let’s change open_airports/0 once again. This time we’ll replace Stream.map/2 and Stream.reject/2 with Flow.map/2 and Flow.reject/2 respectively. Make sure to measure the performance afterward. Here is how the code looks after the changes:

Get hands-on with 1200+ tech skills courses.