How to update a subset of objects using ngrx-entity?

I am updating a set of objects using an HTTP patch request to a remote server. The response from the backend includes only updated objects (i.e. not all entities).

I installed my reducer with an object state adapter and used updateManyto update my objects:

case settings.SettingsActionTypes.UpdateSettingsSuccess: {
   return {
     ...state,
     ...adapter.updateMany(action.payload.map((category) => Object.assign({}, {id: category.name, changes: category})), state),
     loaded: true,
     loading: false,
   }
 }

When updating entities that have received the update, all others that are not returned by the backend are deleted.

Is there a way to tell ngrx to only update the objects included in action.payload?

+6
source share
1 answer

You should not be distributed so many times.

, fu.

return adapter.updateMany( 
   action.payload.map((category) => Object.assign({}, {id: category.name, changes: category})), 
   { ...state, loaded: true, loading: false }
);
+3

All Articles