-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Description
Feature request
I would like to see set of methods for bulk work with arrays items. They might be built on top of existing ones (e.g. set, merge, toggle, etc).
Example of verbose code:
const units = state.units.map(unit => {
if (unit.team === team) {
return ({ ...unit, selected: true });
} else {
return unit;
}
});
state = { ...state, units };
we can invent something like:
state = dotProps.mergeForArrayItems(state, 'units', { selected: true }, unit => unit.team === team);
or using dedicated namespace
state = dotProps.array.merge(state, 'units', { selected: true }, unit => unit.team === team);
// signature: merge(obj, prop, val [, predicate])
Reactions are currently unavailable