In Redux framework there is a store which maintain state of application (store is single source of truth). so the store is use throughout the application. all components share the store. So its very easy to have communication in between the components regardless of at what level component comes. As we have seen in previous post whenever we wants to change the state then we need to dispatch action. but updating store is not taken care by dispatching action only. we need to handled that dispatched action and do the update. As we have to maintain state as mutable we need a function which will be the pure function which will change the state and return new state. Yes, reducer is that function. We already defined reducer. "Reducer is pure function which alter the state of store and return the new state" So how can we write reducers in Angular Reducer function takes 2 parameters 1. State - current state of application 2. action - action to perform ...
Actions are nothing but just javascript object. When we want to change the state of store then there is no option rather than dispatching the actions. Dispatching action is the only way by which we can change the state of store. Action contains two properties: 1. Type 2. Payload Type is nothing but simple plain string to identify what kind of action it is e.g "Update_Employee" / "Delete_Employee" Payload is data required for performing the action e.g suppose we have to dispatch "Update_Employee" Action but, to perform this action we need updated employee's data so that we can alter the state of store so in this case updated employee's details will be the payload for this action so basic structure of action will be like below { type: "Update_Employee", payload : { employeeId : 101, name : "John Tot", Address : "-----" } } When we are imple...