onEmpty
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, 2
Content copied to clipboard