I have the following action
export const updateSuccess = createAction('Success', props<{ someId: string }>());
And I have an adapter in the reducer like this
export const adapter: EntityAdapter<Model> = createEntityAdapter<Model>({
selectId: (item: Model) => item.someId,
sortComparer: false
});
Now when I update an item, the backend is sending that someId
. So I do not have the full Model data at that point. So I was thinking I need to filter the entities I have in the state and upsertOne
with that filtered item.
So something like this
on(actions.updateSuccess, (state, payload) =>
adapter.upsertOne(state.entities.filter(entitiy => entity.someId === payload.someId), { ...state, someOtherProperties: 'values' })
),
But this looks incorrect and gives errors. How can I do this?