onEmpty
fun <T> Flow<T>.onEmpty(action: suspend FlowCollector<T>.() -> Unit): Flow<T>
Content copied to clipboard
Invokes the given action when this flow completes without emitting any elements. The receiver of the action is FlowCollector, so onEmpty can emit additional elements. For example:
emptyFlow<Int>().onEmpty {
emit(1)
emit(2)
}.collect { println(it) } // prints 1, 2Content copied to clipboard