Streams
Let’s learn about the properties and uses of streams in Elixir.
We'll cover the following
Streams
Streams provide some beautiful properties, as Elixir can be lazy when we want it to be. Lazy functional languages delay the execution of a sequence until the values are needed. The Stream
module is the implementation of Elixir’s laziness. It’s full of functions that don’t compute values until they are needed. Elixir’s streams deal with large data blocks and infinite sequences while avoiding unnecessary computation.
Uses of streams
Some of the common uses of streams are to:
-
Deal with massive datasets, data of indeterminate size, or data from external sources.
-
Delay execution for computed lists.
The following commands are an example of a stream being used to perform functions on a list:
Executable
Get hands-on with 1200+ tech skills courses.