Is there some sort of extra reducers for rtk query endpoint? #4852
              
                Unanswered
              
          
                  
                    
                      MaximKondratev
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment 1 reply
-
| onQueryStarted is the right place for this. You can't add more reducers to the RTK Query slice after it's created. If you wanted to respond to some other action (not something covered by queryFulfilled) you could use a listener: startListening({
  actionCreator: hydrateMyQuery,
  effect: (action, { dispatch }) => dispatch(myApi.endpoints.myQuery.upsertQueryData(action.payload))
})but that seems like a rare case. | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
There is a way to use
extraReducersof asliceto do something with slice state depending on rtk query actions like matchFulfilled (example from the docs)Is there a way to do similar things for a query itself? I have two queries and when one fulfills I want to fill (upsert or update) second query with data from first query.
Right now I am able to do it this way:
But I want to do it the other way. I want to subscribe secondQuery to match firstQuery fulfill and change state with result:
I'm pretty sure it's impossible but maybe I just can't find it in the docs
Beta Was this translation helpful? Give feedback.
All reactions