Reputation: 9380
I have a flow:
fun startCountingTimer(coroutineContext: CoroutineContext, leftSeconds: Int): Flow<Int> {
return flow {
for (i in leftSeconds downTo 0) {
delay(1000)
emit(i)
}
}
}
I want to collect it from one place :
startWaitingTimer().collect {
...
}
and cancel from another:
startWaitingTimer().cancel()
How to do it?
Upvotes: 1
Views: 202