cached_query icon indicating copy to clipboard operation
cached_query copied to clipboard

More Examples

Open TC3000 opened this issue 1 year ago • 1 comments

Hello, thanks very much for a great package, got a few questions..

first, could we please have more examples of cached_query, perhaps alongside some state management solutions such as flutter_bloc?

second, does cached_query aides or replaces something like hydrated_bloc?

and lastly, is it possible to use cached_query in my app to offer offline capabilities? Meaning could users make operations without an internet connection and have those operations executed once they have a connection?

TC3000 avatar Apr 01 '23 11:04 TC3000

Hello,

There are a couple examples with flutter_bloc on the documentation website and there are more I use for testing in the examples folder. Do you have any specific examples you think are worth covering? I am happy to add more.

second, does cached_query aides or replaces something like hydrated_bloc?

(I do not personally use hydrated bloc, I use flutter_bloc though) As i understand it, hydrated bloc is for persisting bloc state to disk using some storage package (hive/sqflite etc..). Hydrated bloc and cached query are intended for different areas of the app and with different use cases .So you could definitely use hydrated bloc along side cached_query depending on what you need. For example, you may use hydrated_bloc to save the state of a user's form, and use cached_query to cache normal api requests. You could even use cached_storage with cached_query to store api requests to disk.

and lastly, is it possible to use cached_query in my app to offer offline capabilities?

Yes and No. cached_storage (a storage package for cached query) can help with saving api requests for offline usage. It is designed for simple use cases. Eg, showing some initial data instead of a loading screen or showing items previously fetched when offline. Cached api requests will be visible offline but it is not intended as an offline-first package. It is just intended to increase the user experience when dealing with server state.

Meaning could users make operations without an internet connection and have those operations executed once they have a connection?

There is currently no functionality that will save mutations and execute them when the user is back online. Any get request or normal query will be re-fetched when the user comes back online. But this doesn't happen with mutations. I'm currently unsure of the best way to do this. For example, say a user fills a form but doesn't have an internet connection. They come back to the app in 5 days time, should the form still be send? I am open to any ideas on this subject.

D-James-GH avatar Apr 02 '23 20:04 D-James-GH