- STATE PASSING TO REDUCER
- We know that Reducer needs the current state, and the action (with Payload) to create the new state
- Note that while dispatching the action, we don’t pass it the current state, but instead only the action type and the payload.
- The job of providing the reducer with the current state resides with ngRx.
- Similarly, the reducer only returns the new state, and doesn’t interact with the store. The job of updating the store also is done by ngRx implicitly.
- STORE MUTATION
- If the reducer doesn’t emit a new Store, and instead mutates a deep property of the store, then the subscriber observing that property of the store doesn’t get notified…
- Hence always use the spread operator or object.assign to clone the original store before updating it inside the reducer