myanmarking
03/17/2020, 1:07 PMpublic fun <T> Flow<T>.onEmpty(action: suspend FlowCollector<T>.() -> Unit): Flow<T> {
var valueCount: Int = 0
return flow {
collect { valueCount += 1; emit(it) }
if(valueCount == 0) action()
}
}
does this makes sense in terms of implementation ?elizarov
03/17/2020, 1:48 PMmyanmarking
03/17/2020, 1:49 PMelizarov
03/17/2020, 1:51 PM