LegendApp/legend-state

Handling unsuccessfull network requests with Tanstack Query

Opened this issue · 2 comments

Hello,

I am using persistPluginQuery with persistObservable and I was wondering what to return inside the queryFn for unsuccessfull network calls ?
Currently I am returning the original observable state, but I am not sure if that is the correct way ?

We just released version 3.0 alpha which has a new sync system which may take care of all your needs so you don’t need Query anymore. But it also includes a new Query plugin if you prefer that. And now the answer depends largely on what you want to do with unsuccessful network requests. If you throw an error it will trigger it to retry. If that’s not what you want, can you tell me more about how you’d like to handle network failures?

See the new sync docs: https://legendapp.com/open-source/state/v3/sync/persist-sync
And the Query plugin docs: https://legendapp.com/open-source/state/v3/sync/tanstack-query/

this looks promising!
my ultimate goal would be to have a saved queue which handles errors, e.g. if a request fails ( or if no internet connection is there ) the request should stay in queue and be retried once connection is up again or on next start of the app