-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
NETWORK_THEN_CACHE policy. #18
Comments
Meanwhile it is better if I specify the policies currently provided and the behavior of the library in the offline state. This is the behavior of the library when the application status is
Another element that has been added inside the library is the management of the TTL of the queries that allows to define how long the data inside the store must be considered good. When the library status is it's provided the automatic management of the STORE_ONLY policy is foreseen within the logic of the QueryRenderer. This means that when the component is rendered, the network status is checked and if it is offline, no request is made on the network. Furthermore, if the application is offline the garbage collector is disabled. Aren't these features sufficient to cover this requirement? |
Thanks very much for that explanation, it's really helpful! I think this helps me explain the problem I'm running into. The current options do not seem sufficient for tackling this scenario: I have a screen that loads a user profile, so requests data from a
Before the user is logged in,
returned So when the Profile screen is loaded, and the ProfileScreenQuery is made, this is my understanding of what happens:
In summary, the use-case for NETWORK_THEN_CACHE would be any case where only "complete" data is acceptable, (which we know we have if we've made that query before). So I guess you could describe what I'm looking for as "STORE_THEN_NETWORK if we've made the query before, but NETWORK_ONLY if it this is the first time we're running this query". |
even when executing the query with NETWORK_ONLY it is necessary to loading. |
I guess that's a decent work around. However, this problem repeats itself in multiple places in the tree. Say we update ProfileScreenQuery to include a
Now the store will be missing "age" the first time this query is made, so we need another loading screen that shows the loading screen if There are so many variations of this problem that it would make sense to just hash the query and store it as a "has been made" (which indicates whether the cached result is usable enough). Without a feature like this, we'd end up with lots of components looking like this: |
For this problem I recommend following this issue and the official response |
I've now realised the behaviour I was looking for was the default behaviour of NETWORK_ONLY when using this library 🤦♂. Thank you for the help! The missing data problem is definitely interesting and still worth thinking about for users of STORE_THEN_NETWORK. |
This issue is to discuss how to handle cases where we would like to try to make a network request first before using the store/cache.
This is desirable where we prefer up-to-date information, but will settle for out of data information. It seems like a common use case for offline apps, making it worth at least discussing in the context of this library.
An example might be trying to fetch comments. We don't want to show the old comments if the new ones are available, but rather want to try to fetch the latest comments first, but are happy to default to showing the old ones if necessary.
The text was updated successfully, but these errors were encountered: