-
Notifications
You must be signed in to change notification settings - Fork 271
Closed
Description
In Step 9, we are asked to complete the initSearch with the following lines of code:
// Scroll to top when the list is refreshed from network.
lifecycleScope.launch {
adapter.loadStateFlow
// Only emit when REFRESH LoadState changes.
.distinctUntilChangedBy { it.refresh }
// Only react to cases where REFRESH completes i.e., NotLoading.
.filter { it.refresh is LoadState.NotLoading }
.collect { binding.list.scrollToPosition(0) }
}
However, at the end of the Step 9, the finished code for initSearch uses the following:
lifecycleScope.launch {
@OptIn(ExperimentalPagingApi::class)
adapter.dataRefreshFlow.collect {
binding.list.scrollToPosition(0)
}
}
Did I miss anything during the course of doing Step 9? Or is something really missing? I guess the final code is functionally the same with the intermediate code, but it's a little bit puzzling for me.
Metadata
Metadata
Assignees
Labels
No labels