Posts

Showing posts with the label ngrx

NgRx - Reducers priority and execution order against store

NgRx - Reducers priority and execution order against store If different reducers are associated to the same action and are performing changes to the store, are they receiving the same version of it before any edit happens? Is there a priority to consider? Example: Lets assume you dispatch an action Update to edit an entity on server side, once data is successfully updated, an effect will dispatch an Update_Success action with an instance of the newly received version of entity as payload. A first classic and logical reducer will use it to update the store: Update Update_Success case ItemActionTypes.UPDATE_ITEM_SUCCESS: { const item = action.payload; return { ...adapter.upsertOne(item, state), loaded: true, loading: false }; } Now lets assume that in a different file, you have a different reducer associated to the same action and needs to compare the newly received entity against the old one in store: case ItemActionTypes.UPDATE_ITEM_SUCCESS: { const item =...