11 ms·
Still requires boilerplate for thunks, which in my case is most redux actions. Also I think you still don't support for specifying same reducer for many actions
by damidekronik 7y ago
Still requires boilerplate for thunks, which in my case is most redux actions. Also I think you still don't support for specifying same reducer for many actions (for example as an array - https://github.com/piotrwitek/typesafe-actions https://github.com/piotrwitek/typesafe-actions). The immutable update logic however is amazing and I am glad I got introduced to it by you!
- acemarke 7y agoNot sure what you mean by "boilerplate for thunks". You write thunks the same way you always have. And yes, `createSlice` explicitly supports responding to actions that were defined elsewhere in the app, using the `extraReducers` argument: https://redux-toolkit.js.org/api/createSlice#extrareducers https://redux-toolkit.js.org/api/createSlice#extrareducers Although... are you saying that you want one reducer function to handle many different actions in one slice? Just define the reducer outside the slice itself, and pass it as the handler for each action: createSlice({ name: "someSlice", initialState, reducers: { action1: someCaseReducer, action2: someCaseReducer, } }) Did something similar in my own app recently at work, where multiple slices all needed to handle loading data similarly. So, I wrote a couple generic reducers, and passed them in to each of the slices.