createSlicecreateActioncreateAsyncThunkconfigureStore
- Reduce boilerplate
- Increase cohesion
- Add magic (immutable mutations, action conventions)
- redux toolbox has
thunkmiddleware out of the box configureStoreallows to reconfigure middleware, so we are able to inject servicescreateAsyncThunkis where we keep logic and consume services- Promises and
pending,fullfiledandrejectedactions - 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