# StaticListPagingSourceFactoryKt

Added in 3.2.0

*** ** * ** ***


```
public final class StaticListPagingSourceFactoryKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingSourceFactory<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull Value>` | `@https://developer.android.com/reference/androidx/annotation/VisibleForTesting <Value extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/testing/StaticListPagingSourceFactoryKt#(kotlin.collections.List).asPagingSourceFactory()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull Value> receiver)` Returns a `https://developer.android.com/reference/androidx/paging/PagingSourceFactory` that creates `https://developer.android.com/reference/androidx/paging/PagingSource` instances. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingSourceFactory<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Integer.html, @https://developer.android.com/reference/androidx/annotation/NonNull Value>` | `@https://developer.android.com/reference/androidx/annotation/VisibleForTesting <Value extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/paging/testing/StaticListPagingSourceFactoryKt#(kotlinx.coroutines.flow.Flow).asPagingSourceFactory(kotlinx.coroutines.CoroutineScope)( @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/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull Value>> receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html coroutineScope )` Returns a `https://developer.android.com/reference/androidx/paging/PagingSourceFactory` that creates `https://developer.android.com/reference/androidx/paging/PagingSource` instances. |

## Public methods

### asPagingSourceFactory

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

```
@VisibleForTesting
public static final @NonNull PagingSourceFactory<@NonNull Integer, @NonNull Value> <Value extends Object> asPagingSourceFactory(@NonNull List<@NonNull Value> receiver)
```

Returns a `https://developer.android.com/reference/androidx/paging/PagingSourceFactory` that creates `https://developer.android.com/reference/androidx/paging/PagingSource` instances.

Can be used as the pagingSourceFactory when constructing a `https://developer.android.com/reference/androidx/paging/Pager` in tests. The same factory should be reused within the lifetime of a ViewModel.

Extension method on a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` of data from which a `https://developer.android.com/reference/androidx/paging/PagingSource` will load from. While this factory supports multi-generational operations such as `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH`, it does not support updating the data source. This means any PagingSources generated by the same factory will load from the exact same list of data.

### asPagingSourceFactory

Artifact: [androidx.paging:paging-testing](https://developer.android.com/jetpack/androidx/releases/paging) [View Source](https://cs.android.com/search?q=file:androidx/paging/testing/StaticListPagingSourceFactory.kt+function:asPagingSourceFactory) Added in [3.2.0](https://developer.android.com/jetpack/androidx/releases/paging#3.2.0)

```
@VisibleForTesting
public static final @NonNull PagingSourceFactory<@NonNull Integer, @NonNull Value> <Value extends Object> asPagingSourceFactory(
    @NonNull Flow<@NonNull List<@NonNull Value>> receiver,
    @NonNull CoroutineScope coroutineScope
)
```

Returns a `https://developer.android.com/reference/androidx/paging/PagingSourceFactory` that creates `https://developer.android.com/reference/androidx/paging/PagingSource` instances.

Can be used as the pagingSourceFactory when constructing a `https://developer.android.com/reference/androidx/paging/Pager` in tests. The same factory should be reused within the lifetime of a ViewModel.

Extension method on a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` of list that represents the data source, with each static list representing a generation of data from which a `https://developer.android.com/reference/androidx/paging/PagingSource` will load from. With every emission to the flow, the current `https://developer.android.com/reference/androidx/paging/PagingSource` will be invalidated, thereby triggering a new generation of Paged data.

Supports multiple factories and thus multiple collection on the same flow.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html coroutineScope` | the CoroutineScope to collect from the Flow of list. |