Redux Saga
Redux is used as a middleware to manage the whole app’s state in a centralised location called store. By using store all the components can reach the state, edit it and get the changes from other components.Sagas are implented by using generator functions.
Rules
- Keep Sagas small and focused
- Use yield effects to handle side effects
- Use the appropriate saga effect for the task
- Use error handling: Working with asynchronous code, it's important to handle errors properly. Redux Saga provides a variety of ways to handle errors, such as try/catch blocks
- To dispatch an action, use the
puteffect. - To access redux store, use
selecteffect.
Structure and Naming
Inside /redux folder contains all the redux resources.
- The
root reducerfile combines all the reducers. - The
root sagafile combines all the sagas into a single root saga. - The
configureStorefile contains the logic to configure the Redux store and middlewares. - For naming use camel case
- saga name:
sagaName.saga.ts - slice name:
sliceName.slice.ts
- saga name: