Executes an effectful fold over the stream of values.
Concatenates with another stream in strict order
Allow a faster producer to progress independently of a slower consumer by buffering
up to capacity
elements in a queue.
Allow a faster producer to progress independently of a slower consumer by buffering
up to capacity
elements in a queue.
when possible, prefer capacities that are powers of 2 for better performance.
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.
Appends another stream to this stream.
Appends another stream to this stream. The concatenated stream will first emit the
elements of this stream, and then emit the elements of the other
stream.
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
.
Executes the provided finalizer after this stream's finalizers run.
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.
Returns a stream made of the concatenation in strict order of all the streams
produced by passing each element of this stream to f0
Maps each element of this stream to another stream and returns the
non-deterministic merge of those streams, executing up to n
inner streams
concurrently.
Maps each element of this stream to another stream and returns the
non-deterministic merge of those streams, executing up to n
inner streams
concurrently. Up to outputBuffer
elements of the produced streams may be
buffered in memory by this operator.
Reduces the elements in the stream to a value of type S
Consumes all elements of the stream, passing them to the specified callback.
Like ZStream#foreach, but returns a ZManaged
so the finalization order
can be controlled.
Consumes elements of the stream, passing them to the specified callback,
and terminating consumption when the callback returns false
.
Like ZStream#foreachWhile, but returns a ZManaged
so the finalization order
can be controlled.
Repeats this stream forever.
Returns a stream made of the elements of this stream transformed with f0
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.
Effectfully 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.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently. Transformed elements
will be emitted in the original order.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently.
Maps over elements of the stream with the specified effectful function,
executing up to n
invocations of f
concurrently. The element order
is not enforced by this combinator, and elements may be reordered.
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.
Runs the sink on the stream to produce either the sink's result or an error.
Runs the stream and collects all of its elements in a list.
Runs the stream and collects all of its elements in a list.
Equivalent to run(Sink.collectAll[A])
.
Runs the stream purely for its effects.
Runs the stream purely for its effects. Any elements emitted by the stream are discarded.
Equivalent to run(Sink.drain)
.
Repeats elements of the stream using the provided schedule.
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
.
Applies a transducer to the stream, converting elements of type A
into elements of type C
, with a
managed resource of type D
available.
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.