MCPcopy Create free account
hub / github.com/ngrx/platform / updateManyMutably

Function updateManyMutably

modules/entity/src/sorted_state_adapter.ts:107–139  ·  view source on GitHub ↗
(updates: any[], state: any)

Source from the content-addressed store, hash-verified

105
106 function updateManyMutably(updates: Update<T>[], state: R): DidMutate;
107 function updateManyMutably(updates: any[], state: any): DidMutate {
108 const models: T[] = [];
109
110 const didMutateIds =
111 updates.filter((update) => takeUpdatedModel(models, update, state))
112 .length > 0;
113
114 if (models.length === 0) {
115 return DidMutate.None;
116 } else {
117 const originalIds = state.ids;
118 const updatedIndexes: any[] = [];
119 state.ids = state.ids.filter((id: any, index: number) => {
120 if (id in state.entities) {
121 return true;
122 } else {
123 updatedIndexes.push(index);
124 return false;
125 }
126 });
127
128 merge(models, state);
129
130 if (
131 !didMutateIds &&
132 updatedIndexes.every((i: number) => state.ids[i] === originalIds[i])
133 ) {
134 return DidMutate.EntitiesOnly;
135 } else {
136 return DidMutate.Both;
137 }
138 }
139 }
140
141 function mapMutably(map: EntityMap<T>, state: R): DidMutate;
142 function mapMutably(updatesOrMap: any, state: any): DidMutate {

Callers 3

updateOneMutablyFunction · 0.70
mapMutablyFunction · 0.70
upsertManyMutablyFunction · 0.70

Calls 2

takeUpdatedModelFunction · 0.85
mergeFunction · 0.85

Tested by

no test coverage detected