arrow-fx-coroutines / arrow.fx.coroutines.stream / onComplete

onComplete

fun <O> Stream<O>.onComplete(s2: () -> Stream<O>): Stream<O>

Run s2 after this, regardless of errors during this, then reraise any errors encountered during this.

Note: this should not be used for resource cleanup! Use bracket or onFinalize instead.

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream(1, 2, 3).onComplete { Stream(4, 5) }
    .toList().let(::println) // [1, 2, 3, 4, 5]
//sampleEnd

Do you like Arrow?

Arrow Org
<