Mjuresic
01/24/2023, 12:37 PMefemoney
01/24/2023, 1:03 PMmyScope.launch {
sharedFlow.subscriptionCount
.map { it > 0 }
.distinctUntilChanged()
.collect { hasNewSubscribers -> toggleRefreshOnOrOff(hasNewSubscribers) }
}
myScope.launch { // coroutine to refresh
var tick = 0
while(true) {
val duration = when(count++ mod 2) {
0 -> 5.minutes
1 -> 30.minutes
}
delay(duration)
triggerRefresh()
}
or something like thatstantronic
01/24/2023, 4:58 PMMjuresic
01/24/2023, 10:16 PM