RTK Query: Toast notification content contingent on multiple PUT responses #2981
-
Hello! I'm toying with the idea of using RTK Query as I rebuild an app that leverages Redux Sagas. I've thoroughly read through the documentation, but I'm stumped on determining if RTK Query would be appropriate for the following use case:
Right now we handle this using Redux Sagas. We Is this concept achievable with RTK Query alone? Note: I see the documentation for Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That's definitely not achievable just with RTKQ, because RTKQ is just about the data fetching aspect. So yes, that's where listeners would come in, and listeners are much more flexible than "a single action" :) Per https://redux-toolkit.js.org/api/createListenerMiddleware#startlistening , you can provide any one of the four options for deciding when an effect is kicked off:
If you need to run logic in a sequence, you could kick off the effect when it sees the first qualifying action, then do |
Beta Was this translation helpful? Give feedback.
That's definitely not achievable just with RTKQ, because RTKQ is just about the data fetching aspect.
So yes, that's where listeners would come in, and listeners are much more flexible than "a single action" :)
Per https://redux-toolkit.js.org/api/createListenerMiddleware#startlistening , you can provide any one of the four options for deciding when an effect is kicked off:
type
oractionCreator
: an exact match against the action type stringmatcher
: a function that can be any combination of the RTK "matcher" utilities, such asisAnyOf(action1, action2, action3)
predicate
: any function with a signature of(action, prevState, currentState) => boolean
, with arbitrary comparison logic inside