Skip to content

rtkQuery lifecycle hook to invalidate cache from side-effects #2389

Closed
@schadenn

Description

@schadenn

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 the reject 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 the invalidateTags 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions