collectSafe

suspend fun <T> Flow<T>.collectSafe(catchTimeout: Boolean, collector: FlowCollector<T>)(source)

Collect Flow without throwing an exception, except CancellationException to cancel parent jobs. Tries to emit a single value if Flow.collect can not be called.

Parameters

collector

the FlowCollector where you want to receive values.


suspend fun <T> Flow<T>.collectSafe(collector: FlowCollector<T>)(source)
suspend fun <T> StateFlow<T>.collectSafe(collector: FlowCollector<T>)(source)


suspend fun <T> StateFlow<T>.collectSafe(catchTimeout: Boolean, collector: FlowCollector<T>)(source)

Collect StateFlow without throwing an exception, except CancellationException to cancel parent jobs. Tries to emit a single value if StateFlow.collect can not be called.

Parameters

collector

the FlowCollector where you want to receive values.