Executes an effectful fold over the stream of values.
Concatenates the specified stream to this stream.
Performs a filter and map in a single step.
Transforms all elements of the stream for as long as the specified partial function is defined.
Converts this stream to a stream that executes its effects but emits no elements.
Converts this stream to a stream that executes its effects but emits no elements. Useful for sequencing effects using streams:
(Stream(1, 2, 3).tap(i => ZIO(println(i))) ++ Stream.lift(ZIO(println("Done!"))).drain ++ Stream(4, 5, 6).tap(i => ZIO(println(i)))).run(Sink.drain)
Drops the specified number of elements from this stream.
Drops all elements of the stream for as long as the specified predicate
evaluates to true
.
Filters this stream by the specified predicate, retaining all elements for which the predicate evaluates to true.
Filters this stream by the specified effectful predicate, retaining all elements for which the predicate evaluates to true.
Filters this stream by the specified predicate, removing all elements for which the predicate evaluates to true.
Maps each element of this stream to another stream, and returns the concatenation of those streams.
Consumes all elements of the stream, passing them to the specified callback.
Consumes elements of the stream, passing them to the specified callback,
and terminating consumption when the callback returns false
.
Repeats this stream forever.
Maps over elements of the stream with the specified function.
Statefully maps over the elements of this stream to produce new elements.
Statefully and effectfully maps over the elements of this stream to produce new elements.
Maps each element to a chunk, and flattens the chunks into the output of this stream.
Maps over elements of the stream with the specified effectful function.
Merges this stream and the specified stream together.
Merges this stream and the specified stream together to produce a stream of eithers.
Merges this stream and the specified stream together to a common element type with the specified mapping functions.
Peels off enough material from the stream to construct an R
using the
provided Sink
, and then returns both the R
and the remainder of the
Stream
in a managed resource.
Peels off enough material from the stream to construct an R
using the
provided Sink
, and then returns both the R
and the remainder of the
Stream
in a managed resource. Like all Managed
resources, the provided
remainder is valid only within the scope of Managed
.
Repeats the entire stream using the specified schedule.
Repeats the entire stream using the specified schedule. The stream will execute normally, and then repeat again according to the provided schedule.
Repeats elements of the stream using the provided schedule.
Runs the sink on the stream to produce either the sink's result or an error.
Takes the specified number of elements from this stream.
Takes all elements of the stream for as long as the specified predicate
evaluates to true
.
Adds an effect to consumption of every element of the stream.
Converts the stream to a managed queue.
Converts the stream to a managed queue. After managed queue is used, the queue will never again produce values and should be discarded.
Applies a transducer to the stream, which converts one or more elements
of type A
into elements of type C
.
Zips this stream together with the specified stream.
Zips two streams together with a specified function.
Zips this stream together with the index of elements of the stream.
A
Stream[E, A]
represents an effectful stream that can produce values of typeA
, or potentially fail with a value of typeE
.Streams have a very similar API to Scala collections, making them immediately familiar to most developers. Unlike Scala collections, streams can be used on effectful streams of data, such as HTTP connections, files, and so forth.
Streams do not leak resources. This guarantee holds in the presence of early termination (not all of a stream is consumed), failure, or even interruption.
Thanks to only first-order types, appropriate variance annotations, and specialized effect type (ZIO), streams feature extremely good type inference and should almost never require specification of any type parameters.