in PagingWithNetworkSample/lib/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/paging/LoadStatesMerger.kt [74:102]
fun updateFromCombinedLoadStates(combinedLoadStates: CombinedLoadStates) {
computeNextLoadStateAndMergedState(
sourceRefreshState = combinedLoadStates.source.refresh,
sourceState = combinedLoadStates.source.refresh,
remoteState = combinedLoadStates.mediator?.refresh,
currentMergedState = refreshState,
).also {
refresh = it.first
refreshState = it.second
}
computeNextLoadStateAndMergedState(
sourceRefreshState = combinedLoadStates.source.refresh,
sourceState = combinedLoadStates.source.prepend,
remoteState = combinedLoadStates.mediator?.prepend,
currentMergedState = prependState,
).also {
prepend = it.first
prependState = it.second
}
computeNextLoadStateAndMergedState(
sourceRefreshState = combinedLoadStates.source.refresh,
sourceState = combinedLoadStates.source.append,
remoteState = combinedLoadStates.mediator?.append,
currentMergedState = appendState,
).also {
append = it.first
appendState = it.second
}
}