MobileNativeFoundation / Store

A Kotlin Multiplatform library for building network-resilient applications
https://mobilenativefoundation.github.io/Store/
Apache License 2.0
3.16k stars 197 forks source link

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

Closed SumeraMartin closed 4 years ago

SumeraMartin commented 4 years ago

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 commented 4 years ago

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

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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

JavierSegoviaCordoba commented 3 years ago

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

OrhanTozan commented 2 years ago

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