orElse

If the primary source completes without emitting any elements, the elements from the secondary source are emitted.

Fan-in operators

Signature

def orElse[U >: Out, Mat2](secondary: Graph[SourceShape[U], Mat2]): Repr[U]
def orElseMat[U >: Out, Mat2, Mat3](secondary: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) ⇒ Mat3): ReprMat[U, Mat3]

Description

If the primary source completes without emitting any elements, the elements from the secondary source are emitted. If the primary source emits any elements the secondary source is cancelled.

Note that both sources are materialized directly and the secondary source is backpressured until it becomes the source of elements or is cancelled.

Signal errors downstream, regardless which of the two sources emitted the error.

emits when an element is available from first stream or first stream closed without emitting any elements and an element is available from the second stream

backpressures when downstream backpressures

completes the primary stream completes after emitting at least one element, when the primary stream completes without emitting and the secondary stream already has completed or when the secondary stream completes

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.