-
-
Notifications
You must be signed in to change notification settings - Fork 96
Elaborate Immediate Mutation Updates / Create section #358
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
Comments
Imperatively refetching can be done with https://resthooks.io/docs/api/useFetcher For adding a new item to a list, you won't have to wait on the refetch if you use https://resthooks.io/docs/api/useFetcher#updateparams-destshape-destparams-updatefunction - tho admittedly that's a bit more finessing to get right. |
@ntucker thanks for the links! I've actually tried to use |
I'm having the same problem with respect to updating a child array. Despite using I'm with @dair-targ... I'm either using the API wrong and the docs could use some clarity on this scenario or there's a bug in the cache provider. |
@smith-it Try the latest 5 release. It includes #360 which makes deletes behave in a more predictable way. It should cause any schema trying to use them still to suspend so they can be accurate. @dair-targ Seems unavoidable to imperatively fetch via usefetcher then. useInvalidator could be used if you want to suspend instead of just fetch in background. (be sure to use latest 5 release to have this behavior work in predictable way) |
#760 allows for full entity changes rather than just primary keys. Tracking this in new design there. |
Is your feature request related to a problem? Please describe.
I was working on a project where I needed to trigger re-fetching the list of resource instances (e.g. order items) and force-update of all the components displaying such a list in cases when a) the new resource instance was created and b) some other resource instance (e.g. account preference) changed.
I've tried to follow the instructions given in the Immediate Mutation Updates (update and create sections), but didn't manage to come up with a reliable solution, most likely because of misuse and misunderstanding of the APIs.
Describe the solution you'd like
It would be great to have more elaborated documentation that would show examples of how to properly trigger re-fetching of the list of resources once a new instance is created, and also do so once some other resource changed.
Could it be done using
useInvalidator()
?Describe alternatives you've considered
Add a section that outlines some common usage patterns.
The text was updated successfully, but these errors were encountered: