May 2, 2024
It's quite simple: just add another mapLatest{} on top of the ticker mapLatest{}:
refreshVersionFlow.mapLatest {
synchronizedTickerFlow(REFRESH_PERIOD, subscriptionCount)
.mapLatest {
repository.loadSomeData()
}
}
}
In this example, refreshVersionFlow is StateFlow<Int> that you increment on each manual refresh request.
This will have the effect of restarting the ticker flow from scratch.