-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
rtkQuery lifecycle hook to invalidate cache from side-effects #2389
Comments
Sorry, not sure I'm following the described scenario here. Can you give some concrete examples, and maybe show what the imaginary code for this feature might look like? |
Okay so let's say you're working on a big application together with some other teams. You're managing a section that shows blog posts and there is another team that owns an admin section somewhere else. You're able to edit blog posts from the admin section.
Now you have the same dependency the other way around, but it might make more sense for the admin section to export their checkers, then to maintain a list of callbacks to trigger in case the changes happen. |
Hmm. Is the https://redux-toolkit.js.org/rtk-query/api/createApi#onquerystarted basically what you're looking for, or is there some difference in behavior / timing from that function? |
|
Hi everyone,
I am currently experiencing a use-case that seems like it is not treated at all at the moment:
I have a query that may have its results invalidated by a side effect that is not within my control (as in: I can't call the invalidate function when the side effect happens).
Now I'm thinking it would be great to have something like a
onQueryInitiated
lifecycle event which will be triggered before thereject
action would be triggered and therefore provide an integration point to check if the mentioned side effects happened in the meantime and if yes - call theinvalidateTags
function.At the moment the only way to do this would be to wrap the autogenerated hook, which feels a little cumbersome.
Wdyt? I'd try implementing this if it is considered to be a good idea.
The text was updated successfully, but these errors were encountered: