Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use paged content with Store? #63

Closed
SumeraMartin opened this issue Jan 14, 2020 · 8 comments
Closed

Is it possible to use paged content with Store? #63

SumeraMartin opened this issue Jan 14, 2020 · 8 comments

Comments

@SumeraMartin
Copy link

Hi, I'm thinking if it is somehow possible to use paged content with the Store. I want to load feed with the newest data and when the user reaches the end of the feed then I want to load older data and so on.

I know that caching of such results can be hard since items can added, or removed, or moved. So I don't know if it is possible. One solution that I figured out would be to cache only the first page and then load others but I don't know how to implement this with the Store.

Can you help me with that?

Thank you for your response

@ychescale9
Copy link
Contributor

ychescale9 commented Jan 14, 2020

It's hard. I've implemented this in the past without Store by implementing the fetcher and a separate query API:

  • The fetcher loads data from network and writes the values to database (Room).
  • The query API exposes an RxJava Observable<PagedList<Data>> which can be built from DataSource.Factory<Key, Value> in Room's Dao with the Paging library.
  • There's a separate SyncStatusChannel for keeping track of status of the sync (loading, out-of-sync, up-to-date) which the UI can observe along with the data stream.

Not sure if it's possible to integrate Store 4 with the upcoming Paging 3 to make this easier (being able to work with StoreResponse<PagedList<Data>>)?

@cwboyd
Copy link

cwboyd commented Jan 22, 2020

You can also subclass PositionalDataSource and override loadRange and loadInitial and provide a factory to be passed to LivePagedListBuilder. In loadInitial / loadRange (which load multiples, based on specified paging config), you then get data from your store. You gets some flowables back and then have to notify the provided callbacks.

This would probably work with the other implementations of DataSource<K,V> provided by the Paging library.

@yigit
Copy link
Collaborator

yigit commented Feb 29, 2020

FYI i'm looking into this as part of Paging3 but there does not seem to be much benefit in putting store in front with the exception that it might help you cache paging across screens etc, if there is a case like it.
You may also want to put store behind paging but that again really depends on how your paging works, whether data changes locally or not etc. We should keep this open until we have a recommended solution but so far i'm not sure what that will look like.

@steve-the-edwards
Copy link

@yigit at the very least is there currently a way to 'append' data to the stream returned from an existing Key? This would allow for the 'Load More' use case.

@steve-the-edwards
Copy link

@yigit at the very least is there currently a way to 'append' data to the stream returned from an existing Key? This would allow for the 'Load More' use case.

Answering my own question it seems the current answer would be using a persister that returns a flow so that we can have it be the source of truth and append externally to the Store APIs.

@digitalbuddha
Copy link
Contributor

Closing, please use Paging3 on its own. Paging 3 has a multicaster built in and should serve use cases without needing store

@JavierSegoviaCordoba
Copy link

If Store is going to be Multiplatform and Paging 3 is not covering that, can be this implemented in Store?

@OrhanTozan
Copy link
Contributor

So Paging3 has the same caching features Store has, plus paging capabilities? Meaning that Paging3 is superior than Store, feature wise?

matt-ramotar pushed a commit to matt-ramotar/store-mirror that referenced this issue Nov 12, 2022
* rename package from nytimes to dropbox

* Update build.gradle

Co-Authored-By: David Chang <changd@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants