splitWhen

Split off elements into a new substream whenever a predicate function return true.

Nesting and flattening operators

Signature

def splitWhen(substreamCancelStrategy: SubstreamCancelStrategy)(p: Out => Boolean): SubFlow[Out, Mat, Repr, Closed]
def splitWhen(p: Out => Boolean): SubFlow[Out, Mat, Repr, Closed]

Description

Split off elements into a new substream whenever a predicate function return true.

emits an element for which the provided predicate is true, opening and emitting a new substream for subsequent elements

backpressures when there is an element pending for the next substream, but the previous is not fully consumed yet, or the substream backpressures

completes when upstream completes (Until the end of stream it is not possible to know whether new substreams will be needed or not)

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.