Status Update
Comments
vi...@google.com <vi...@google.com> #2
du...@google.com <du...@google.com> #4
Branch: androidx-master-dev
commit 83b0d9c4c606cc5d5aa86eef303ceb538367ad9f
Author: Zac Sweers <pandanomic@gmail.com>
Date: Fri Jul 03 00:22:37 2020
Add paging-rxjava3 artifact
This adds an rxjava3 extensions artifact for paging v3. It's ported from the rx2 artifact, but with all the deprecated APIs from that artifact removed.
I had to update the coroutines version to 1.3.7 (technically 1.3.6 was when it was introduced, but with a serious issue affecting android lint that is fixed in 1.3.7). I don't know how to get those prebuilts updates included in my CL though, not sure if it's necessary. Let me know.
RelNote: "Add RxJava3 compatibility wrappers for PagingSource and
RemoteMediator"
Fixes: 161480176
Test: ./gradlew paging:paging-rxjava3:test
Change-Id: I49ef38fde9b84f92dd272ed0b1cd1719fbbf1761
M buildSrc/build_dependencies.gradle
M buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
M buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
A paging/rxjava3/api/3.0.0-alpha04.txt
A paging/rxjava3/api/current.txt
A paging/rxjava3/api/public_plus_experimental_3.0.0-alpha04.txt
A paging/rxjava3/api/public_plus_experimental_current.txt
A paging/rxjava3/api/res-3.0.0-alpha04.txt
A paging/rxjava3/api/res-current.txt
A paging/rxjava3/api/restricted_3.0.0-alpha04.txt
A paging/rxjava3/api/restricted_current.txt
A paging/rxjava3/build.gradle
A paging/rxjava3/src/main/AndroidManifest.xml
A paging/rxjava3/src/main/java/androidx/paging/rxjava3/PagingRx.kt
A paging/rxjava3/src/main/java/androidx/paging/rxjava3/RxPagingSource.kt
A paging/rxjava3/src/main/java/androidx/paging/rxjava3/RxRemoteMediator.kt
A paging/rxjava3/src/test/java/androidx/paging/RxPagingSourceTest.kt
A paging/rxjava3/src/test/java/androidx/paging/RxRemoteMediatorTest.kt
M settings.gradle
an...@gmail.com <an...@gmail.com> #5
Assuming I have different data sources, which I have to merge before providing the result to UI. Whenever one datasource is changed, I have to invalidate the other one, to refresh the data and perform mapping from <dataSource1> results to <dataSource1 + dataSource2> results.
For example, it can be an application, which uses public API to get e.g. movies list, but stores information about favorite films locally. In this case, whenever "favorite" flag is changed, movies list data source should be invalidated. And it can not be done from UI. For such situation should be a possibility to invalidate data source e.g. via Pager object or something.
du...@google.com <du...@google.com> #6
Whil I understand your idea of internal invalidates of PagingSources, I can provide you an example where it is not possible. Assuming I have different data sources, which I have to merge before providing the result to UI. Whenever one datasource is changed, I have to invalidate the other one, to refresh the data and perform mapping from <dataSource1> results to <dataSource1 + dataSource2> results.
This sounds like something that the .map
transform operator on PagingData
would help with.
For example, it can be an application, which uses public API to get e.g. movies list, but stores information about favorite films locally. In this case, whenever "favorite" flag is changed, movies list data source should be invalidated. And it can not be done from UI. For such situation should be a possibility to invalidate data source e.g. via Pager object or something.
It doesn't make sense for the UI / Presentation layer to handle invalidation, it already does this via .refresh()
. Invalidation is simply a signal for PagingSource
updates. I'm not sure that a favorite flag should warrant multiple layers of PagingSource
, but I think I'm not really understanding what's preventing you from hooking up multiple sources of invalidation.
In this case I would recommend to have one DB table / local cache that PagingSource
loads directly from, and any updates from the API or from favorite flag flipping would get written to the cache and also invalidate PagingSource
. This way you only need to hook up invalidate callbacks from a single source, and you can have independent components writing to the same place.
cl...@gmail.com <cl...@gmail.com> #7
du...@google.com <du...@google.com> #8
Sounds good! Just noting for posterity, my prototype will need to kick out invalidated pagingSources to minimize memory pressure.
cl...@gmail.com <cl...@gmail.com> #9
ap...@google.com <ap...@google.com> #10
Branch: androidx-master-dev
commit 5ac03b4d8c4a234d8c91aecb03361d8d1b856ad3
Author: Clara F <clarafok3@gmail.com>
Date: Thu Nov 19 21:07:43 2020
[GH] A PagingSource Factory that can be invalidated
## Proposed Changes
A PagingSource Factory that stores references to PagingSources for PagingSource invalidation
## Testing
Test: ./gradlew paging:paging-common:test
This is an imported pull request from
Resolves #98
Github-Pr-Head-Sha: 63d2bc166414d4b5134ba1dd5998a2a175ccbe25
GitOrigin-RevId: 037f4fe9037bd1aa255a212091f5b955fe9e4693
Fixes: 160716447
Relnote: "A new abstract class InvalidatingPagingSourceFactory has been added
with an `.invalidate()` API that forwards invalidate to all of the PagingSources
it emits"
Change-Id: Ie71fc1cc974dbc72f42572234ea9053e31b44039
M paging/common/api/current.txt
M paging/common/api/public_plus_experimental_current.txt
M paging/common/api/restricted_current.txt
A paging/common/src/main/kotlin/androidx/paging/InvalidatingPagingSourceFactory.kt
A paging/common/src/test/kotlin/androidx/paging/InvalidatingPagingSourceFactoryTest.kt
Description
Artifact used: androidx.paging:paging-runtime & rxjava2 Version used: 3.0.0-alpha02
In order to call
pagingSource.invalidate()
to deal with the user of my app deleting a row from the paged RV they're looking at, I had to do the following in my ViewModel:Then, elsewhere in the VM I have a reference to the source to call
invalidate
. This feels really, really ugly. I'm aware that I have to pass a factory intoPager
because it can get recreated, but this feels like it's not something I should really have to worry about.It's hard to say what I would prefer, which is why I imagine it's like this!
Keeping a reference to the
Pager
feels less gross than it does forPagingSource
. PerhapsPager
could internally keep a reference to the existingPagingSource
so I could just callPager.invalidate()
and it would do a similar hack internally?Very happy for better or other suggestions. Currently it feels very awkward, and it was super hard to discover that the
.invalidate()
method even existed to call!