This message was deleted.
# android-architecture
s
This message was deleted.
m
You can define a channel and use this channel as an event to emit loadCoins flow
Copy code
private val refreshChannel = ConflatedBroadcastChannel<Unit>()
private val coinsFlow: Flow<Resource<List<Coin>>> = refreshChannel.asFlow().transformLatest { emitAll(loadCoins()) }
val coins = coinsFlow.asLiveData()

fun onSwipeRefresh() {
    refreshChannel.offer(Unit)
}
You can also use live data for refresh
Copy code
private val refreshLiveData = MutableLiveData<Unit>(Unit)
val coins: LiveData<Resource<List<Coin>>> = refreshLiveData.switchMap { loadCoins().asLiveData() }

fun onSwipeRefresh() {
    refreshLiveData.value = Unit
}