--

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.

--

--

Christophe Beyls
Christophe Beyls

Written by Christophe Beyls

Android developer from Belgium, blogging about advanced programming topics.

Responses (1)