Status Update
Comments
ae...@google.com <ae...@google.com>
an...@google.com <an...@google.com>
du...@google.com <du...@google.com> #2
reemission of the same liveData is racy
ri...@gmail.com <ri...@gmail.com> #3
ri...@gmail.com <ri...@gmail.com> #4
an...@google.com <an...@google.com> #5
@Test
fun raceTest() {
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData)
emitSource(subLiveData) //crashes
}
subject.addObserver().apply {
testScope.advanceUntilIdle()
}
}
ri...@gmail.com <ri...@gmail.com> #6
an...@gmail.com <an...@gmail.com> #7
I actually have a WIP fix for it:
if your case is the one i found (emitting same LiveData multiple times, as shown in #5) you can work around it by adding a dummy transformation.
val subLiveData = MutableLiveData(1)
val subject = liveData(testScope.coroutineContext) {
emitSource(subLiveData.map {it })
emitSource(subLiveData.map {it} )
}
de...@gmail.com <de...@gmail.com> #8
Branch: androidx-master-dev
commit af12e75e6b4110f48e44ca121466943909de8f06
Author: Yigit Boyar <yboyar@google.com>
Date: Tue Sep 03 12:58:11 2019
Fix coroutine livedata race condition
This CL fixes a bug in liveData builder where emitting same
LiveData source twice would make it crash because the second
emission registry could possibly happen before first one is
removed as source.
We fix it by using a suspending dispose function. It does feel
a bit hacky but we cannot make DisposableHandle.dispose async
and we do not want to block there. This does not mean that there
is a problem if developer disposes it manually since our emit
functions take care of making sure it disposes (and there is
no other way to add source to the underlying MediatorLiveData)
Bug: 140249349
Test: BuildLiveDataTest#raceTest_*
Change-Id: I0b464c242a583da4669af195cf2504e2adc4de40
M lifecycle/lifecycle-livedata-ktx/api/2.2.0-alpha05.txt
M lifecycle/lifecycle-livedata-ktx/api/current.txt
M lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_2.2.0-alpha05.txt
M lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-livedata-ktx/api/restricted_2.2.0-alpha05.txt
M lifecycle/lifecycle-livedata-ktx/api/restricted_current.txt
M lifecycle/lifecycle-livedata-ktx/src/main/java/androidx/lifecycle/CoroutineLiveData.kt
M lifecycle/lifecycle-livedata-ktx/src/test/java/androidx/lifecycle/BuildLiveDataTest.kt
to...@gmail.com <to...@gmail.com> #9
Workaround is to create another Compose function which takes regular List<T> instead of LazyPagingItems<T> for previewing purposes.
ke...@gmail.com <ke...@gmail.com> #10
ja...@gmail.com <ja...@gmail.com> #11
ma...@migrosonline.ch <ma...@migrosonline.ch> #12
be...@swile.co <be...@swile.co> #13
be...@swile.co <be...@swile.co> #14
(I'm on Chipmunk Beta 2)
th...@palringo.com <th...@palringo.com> #15
da...@gmail.com <da...@gmail.com> #16
With compose 1.2.0-beta01, constructing a static LazyPagingItems like this works for me in interactive preview.
val ordersFlow = flowOf(PagingData.from(orders))
val pagingItems = ordersFlow.collectAsLazyPagingItems()
However, the static preview will only show an empty list of items.
wo...@gmail.com <wo...@gmail.com> #17
I still cannot preview the list. Interactive preview doesn't show it as well.
du...@google.com <du...@google.com> #18
Preview doesn't work in paging-compose at the moment with PagingData
because it has to wait for some work to be done before any items show up, so the first frame is always empty as mentioned in #5. However, it's worth investigating if we can get it to work with static PagingData
like PagingData.from
ai...@googlemail.com <ai...@googlemail.com> #19
ro...@cloudkitchens.com <ro...@cloudkitchens.com> #20
ki...@gmail.com <ki...@gmail.com> #21
+1 our snapshot tests became useless after moving from unpaged lists to paged lists, would be really nice to have a preview functionality so our snapshot tests can keep working
lu...@gmail.com <lu...@gmail.com> #22
Please reopen.
ki...@gmail.com <ki...@gmail.com> #23
Would be great to reopen this or give a reason why it won't be fixed. Seems like an important functionality since like it currently stands we cannot cover paged lists with paparazzi snapshot tests.
cl...@google.com <cl...@google.com> #24
Reopening as it's something we would want for paging-compose.
Paging currently can't support this because as
[Deleted User] <[Deleted User]> #25
[Deleted User] <[Deleted User]> #26
di...@gmail.com <di...@gmail.com> #27
cl...@google.com <cl...@google.com> #28
We are planning to include preview support as part of stable paging-compose.
ri...@gmail.com <ri...@gmail.com> #29
Any dates/timelines?
cl...@google.com <cl...@google.com> #30
Currently planned for Q2/Q3.
ap...@google.com <ap...@google.com> #31
Branch: androidx-main
commit 15fa26db22d9a0d2e00cb3847620bc6ae08561fc
Author: Clara Fok <clarafok@google.com>
Date: Mon May 01 16:53:10 2023
Add support for Paging preview in compose
Paging Compose now supports previewing a list of fake data by creating a PagingData.from(fakeData) and passing the PagingData to a MutableStateFlow. Call the MutableStateFlow<PagingData<Value>>.collectAsLazyPagingItems() to preview.
Test: ./gradlew paging:paging-compose:cC
Test: preview sample in PagingPreviewSample
Bug: 194544557
Relnote: "Paging Compose now supports previewing a list of fake data by creating a PagingData.from(fakeData) and passing the PagingData to a MutableStateFlow. Call the MutableStateFlow<PagingData<Value>>.collectAsLazyPagingItems() to get previewable LazyPagingItems."
Change-Id: I8a78db059776190b833773986825579e96e042d5
M paging/paging-common/src/main/kotlin/androidx/paging/PagingData.kt
M paging/paging-compose/build.gradle
M paging/paging-compose/samples/build.gradle
A paging/paging-compose/samples/src/main/java/androidx/paging/compose/samples/PagingPreviewSample.kt
A paging/paging-compose/src/androidTest/java/androidx/paging/compose/LazyPagingItemsPreviewTest.kt
M paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt
cl...@google.com <cl...@google.com> #32
Fixed internally and will be available in the next Paging release. This bug will be updated with release version at the time.
k....@rebuy.com <k....@rebuy.com> #33
Is it already in 1.0.0-alpha19
? If yes, then could I get an example of how to use it?
cl...@google.com <cl...@google.com> #34
It will be available in the upcoming release on May 24th as paging-compose 1.0.0-alpha20
.
The change does include an example on how to set up
The example has DisplayPaging()
composable inlined within PagingPreview()
composable. This is ONLY FOR sample purposes because of how the @Preview
annotation is rendered in documents. In production code DisplayPaging()
should be its own separate, top-level declaration.
ju...@google.com <ju...@google.com> #35
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.paging:paging-common:3.2.0-alpha06
androidx.paging:paging-compose:1.0.0-alpha20
no...@gmail.com <no...@gmail.com> #36
One important point – inside @Preview
, you should use MutableStateFlow()
rather than builders like flowOf()
– the latter simply doesn’t work
Description
Jetpack Compose release version:1.0.0-rc02
Android Studio Build:Android Studio Bumblebee | 2021.1.1 Canary 4
Kotlin version:1.5.10
I think the title says it all.
LazyPagingItems
constructor is internal. I can't passLazyPagingItems
as parameter in Preview Composable, let alone passing sample data. But I want to show preview of my composable, how should I do this?