0

Is it possible to dispatch to only a specific set of reducers based on the return value of your API? I can't seem to find anything about this in the docs. It would go something like below.

const myAsyncThunk = createAsyncThunk('example',async(req:APIReq) => {
    const reply = await myAPI(req);
    const [tag, payload] = reply;
    if (tag === 'foo') return dispatch fooAction with payload to fooSliceOfState only
    if (tag === 'bar') return dispatch barAction with payload to barSliceOfState only
})
Brandon-Perry
  • 366
  • 4
  • 18

0 Answers0