Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit ca034507266a55c23a6b79e732fdbb7262cad096
Author: Clara Fok <clarafok@google.com>
Date: Fri Aug 26 11:42:32 2022
Add support for custom context in collectAsLazyPagingItems
Context is defaulted to Dispatchers.Main for backcompat.
Test: ./gradlew paging:paging-compose:cC
Fixes: 243182795
Fixes: 233896435
Fixes: 233783862
Relnote: Add support for a custom CoroutineContext when calling collectLazyPagingItems on a Flow<PagingData<T>>
Change-Id: I7a57418bcbd9ab86ddcbed3313b00aa82bf2398f
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
M paging/paging-compose/api/public_plus_experimental_current.txt
M paging/paging-compose/build.gradle
M paging/paging-compose/api/restricted_current.txt
M paging/paging-compose/api/current.txt
M paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
https://android-review.googlesource.com/2199396
Branch: androidx-main
commit ca034507266a55c23a6b79e732fdbb7262cad096
Author: Clara Fok <clarafok@google.com>
Date: Fri Aug 26 11:42:32 2022
Add support for custom context in collectAsLazyPagingItems
Context is defaulted to Dispatchers.Main for backcompat.
Test: ./gradlew paging:paging-compose:cC
Fixes: 243182795
Fixes: 233896435
Fixes: 233783862
Relnote: Add support for a custom CoroutineContext when calling collectLazyPagingItems on a Flow<PagingData<T>>
Change-Id: I7a57418bcbd9ab86ddcbed3313b00aa82bf2398f
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
M paging/paging-compose/api/public_plus_experimental_current.txt
M paging/paging-compose/build.gradle
M paging/paging-compose/api/restricted_current.txt
M paging/paging-compose/api/current.txt
M paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsTest.kt
na...@google.com <na...@google.com> #3
The following release(s) address this bug:
androidx.paging:paging-compose:1.0.0-alpha17
Description
Problem
Currently, Paging flows are collected through
collectAsLazyPagingItems
. The API does not provide a way to specify which coroutine context to use, that leads to collecting the flow on the main thread.the transformation happening on the flow (e.g.
pagingData.map
can be costly and would add up), ideally host app should be able to specify where that runs.right now, the Java api allows to specify an Executor. I believe the same cannot be achieved through the kotlin overload:
pagingData.map
with a context does not propagate (pseudocode):Note that it would be the same behavior if
flowOn
was used to specify another coroutineContext.pagingData.map
would still execute on main thread.pagingData.map
works but results in someProposal
collectAsLazyPagingItems
should take an optional coroutine context and use it like:Where the default value for
coroutineContext
should be backward compatible with current behavior.