EntityAdapter | removeMany with Predicate Function #2695
-
Hi, I search for a way to dispatch a Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not directly, no. The primary issue here is that functions are not serializable, and thus they don't belong in an action:
The best option would be to do a |
Beta Was this translation helpful? Give feedback.
Not directly, no.
The primary issue here is that functions are not serializable, and thus they don't belong in an action:
@ngrx/entity
does actually have aremoveMany(predicate)
option, and RTK'screateEntityAdapter
started as a copy of that package. But, when we reworked the methods to be usable as reducers directly, we had to remove that method to keep usage consistent with Redux patterns.The best option would be to do a
.ids.filter()
, look up the values from the.entities
field, come up with an array of IDs to remove, and pass those toadapter.removeMany(state, ids)
.