# CombinedLoadStatesKt

Added in 3.3.0

*** ** * ** ***


```
public final class CombinedLoadStatesKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final https://developer.android.com/reference/androidx/paging/CombinedLoadStates` | `https://developer.android.com/reference/androidx/paging/CombinedLoadStatesKt#(kotlinx.coroutines.flow.Flow).awaitNotLoading()(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/CombinedLoadStates> receiver)` Function to wait on a Flow until a load has completed. |

## Public methods

### awaitNotLoading

Artifact: [androidx.paging:paging-common](https://developer.android.com/jetpack/androidx/releases/paging) [View Source](https://cs.android.com/search?q=file:androidx/paging/CombinedLoadStates.kt+function:awaitNotLoading)

```
public static final CombinedLoadStates awaitNotLoading(@NonNull Flow<@NonNull CombinedLoadStates> receiver)
```

Function to wait on a Flow until a load has completed.

It collects on the Flow and suspends until it collects and returns the firstOrNull `https://developer.android.com/reference/androidx/paging/CombinedLoadStates` where all `https://developer.android.com/reference/androidx/paging/LoadStates` have settled into a non-loading state i.e. `https://developer.android.com/reference/androidx/paging/LoadState.NotLoading` or `https://developer.android.com/reference/androidx/paging/LoadState.Error`.

A use case could be scrolling to a position after refresh has completed:

```
override fun onCreate(savedInstanceState: Bundle?) {
    ...
    refreshButton.setOnClickListener {
        pagingAdapter.refresh()
        lifecycleScope.launch {
            // wait for refresh to complete
            pagingAdapter.loadStateFlow.awaitNotLoading()
            // do work after refresh
            recyclerView.scrollToPosition(position)
        }
   }
}
```