Fixed
Status Update
Comments
du...@google.com <du...@google.com> #2
This is a good idea and definitely worth investigating.
I think there's something to be said about what scope these coroutines would run in, but it should be possible to pass it back from adapter internally.
du...@google.com <du...@google.com> #3
Thanks for the suggestion!
cc...@google.com <cc...@google.com>
le...@gmail.com <le...@gmail.com> #4
I was thinking of something more upstream. I may be wrong, because I'm just getting started with this new library
Using the scope of the adapter in case of a configuration change would cancel the coroutine, and the cachedIn operator wouldn't cache the mapped value, and some operations would have to be done multiple times.
Maybe using the scope on the producing side of the PageEvents, like in PageFetcher, could be an option.
Using the scope of the adapter in case of a configuration change would cancel the coroutine, and the cachedIn operator wouldn't cache the mapped value, and some operations would have to be done multiple times.
Maybe using the scope on the producing side of the PageEvents, like in PageFetcher, could be an option.
du...@google.com <du...@google.com>
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit debb2cb10010710d92c0da93b7ea6870fbc4d834
Author: Dustin Lam <dustinlam@google.com>
Date: Fri Jun 26 19:45:32 2020
Add suspend version of transform functions
RelNote: "Made existing PagingData operators accept suspending methods
and introduced new mapSync, flatMapSync, and filterSync non-suspending
operators for Java users. The existing transformation methods have been
moved to extension functions so Kotlin users will need to import them."
Fixes: 159983232
Test: ./gradlew paging:paging-common:test
Change-Id: I342390a7b1eb98ac87072998744a9e46c99a1000
M paging/common/api/3.0.0-alpha03.txt
M paging/common/api/current.txt
M paging/common/api/public_plus_experimental_3.0.0-alpha03.txt
M paging/common/api/public_plus_experimental_current.txt
M paging/common/api/restricted_3.0.0-alpha03.txt
M paging/common/api/restricted_current.txt
M paging/common/src/main/kotlin/androidx/paging/PageEvent.kt
M paging/common/src/main/kotlin/androidx/paging/PagingData.kt
M paging/common/src/main/kotlin/androidx/paging/Separators.kt
M paging/common/src/test/kotlin/androidx/paging/PageEventTest.kt
M paging/common/src/test/kotlin/androidx/paging/SeparatorsTest.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3/V3Activity.kt
M paging/samples/src/main/java/androidx/paging/samples/CachedInSample.kt
M paging/samples/src/main/java/androidx/paging/samples/InsertSeparatorsUiModelSample.kt
M paging/samples/src/main/java/androidx/paging/samples/java/InsertSeparatorsJavaUiModelSample.java
https://android-review.googlesource.com/1350688
Branch: androidx-master-dev
commit debb2cb10010710d92c0da93b7ea6870fbc4d834
Author: Dustin Lam <dustinlam@google.com>
Date: Fri Jun 26 19:45:32 2020
Add suspend version of transform functions
RelNote: "Made existing PagingData operators accept suspending methods
and introduced new mapSync, flatMapSync, and filterSync non-suspending
operators for Java users. The existing transformation methods have been
moved to extension functions so Kotlin users will need to import them."
Fixes: 159983232
Test: ./gradlew paging:paging-common:test
Change-Id: I342390a7b1eb98ac87072998744a9e46c99a1000
M paging/common/api/3.0.0-alpha03.txt
M paging/common/api/current.txt
M paging/common/api/public_plus_experimental_3.0.0-alpha03.txt
M paging/common/api/public_plus_experimental_current.txt
M paging/common/api/restricted_3.0.0-alpha03.txt
M paging/common/api/restricted_current.txt
M paging/common/src/main/kotlin/androidx/paging/PageEvent.kt
M paging/common/src/main/kotlin/androidx/paging/PagingData.kt
M paging/common/src/main/kotlin/androidx/paging/Separators.kt
M paging/common/src/test/kotlin/androidx/paging/PageEventTest.kt
M paging/common/src/test/kotlin/androidx/paging/SeparatorsTest.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3/V3Activity.kt
M paging/samples/src/main/java/androidx/paging/samples/CachedInSample.kt
M paging/samples/src/main/java/androidx/paging/samples/InsertSeparatorsUiModelSample.kt
M paging/samples/src/main/java/androidx/paging/samples/java/InsertSeparatorsJavaUiModelSample.java
Description
Could it be possible to transform the signature of PagingData extension function like
map
andflatMap
to accept suspending transform function ?For example :
fun <R : Any> map(transform: (T) -> R): PagingData<R> = transform { it.map(transform) }
tofun <R : Any> map(transform: **suspend** (T) -> R): PagingData<R> = transform { it.map(transform) }
For instance, i'm observing a Room table with a Pager that contains Entity ids in other Room tables (like a polymorphic table), and I would like to query them inside a map in a suspending way and not using runBlocking.