createSlice
createAction
createAsyncThunk
configureStore
- Reduce boilerplate
- Increase cohesion
- Add magic (immutable mutations, action conventions)
- redux toolbox has
thunk
middleware out of the box configureStore
allows to reconfigure middleware, so we are able to inject servicescreateAsyncThunk
is where we keep logic and consume services- Promises and
pending
,fullfiled
andrejected
actions - Hide redux from Components with custom hooks
- slice test is pretty straightforward. We call actions, we see state updates, pure functions at it's greatest
createAsyncThunk
. Action call results in other actions calls, so we might test these. Occasionally we want to test service calls- Components. Ideally we want to check that user-generated action results in a redux action. But in reality we had to go deeper and test service calls.
- It's OK