You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
None of the current tests/ docs demonstrate the use of the error function on modifiers like useUpdateFactory. It would be beneficial to see a basic implementation.
The text was updated successfully, but these errors were encountered:
The error callback is for updating the data in a particular way if an error happens or the promise rejects. It's particularly useful when making optimistic updates to the data store. For example:
User says "I want to POST this data"
Code in the preload updates the store immediately so that the change reflects to the user immediately but is running the API request in the background
API request fails and rejects the promise
The error callback is fired so the data can be reset to it's original value or some other state if you want to handle error states separately.
Really it's only used for optimistic updates, where if you're doing the update only after the API comes back, if the API fails, the store wasn't updated in the first place so there's no clean up required.
I'll leave this open as a reminder to add optimistic update tests in src/context-store--basic/tests so there are examples of this.
None of the current tests/ docs demonstrate the use of the
error
function on modifiers likeuseUpdateFactory
. It would be beneficial to see a basic implementation.The text was updated successfully, but these errors were encountered: