R
Size: a a a
R
R
R
AK
#each
?A
R
R
R
#each
?A
A
КС
A
R
A
КС
$: objectsById = currentObjects.reduce((items, item) => {
items[item.id] = item;
return items;
}, {});
function onEvent(newObjects) {
let objectsToReplace = {};
let objectsToAdd = [];
for (const obj of newObjects) {
if (items[obj.id]) {
objectsToReplace[obj.id] = obj;
} else {
objectsToAdd.push(obj);
}
}
const newObjects = currentObjects.map((obj) => {
return objectsToReplace[obj.id]
? objectsToReplace[obj.id]
: obj;
});
newObjects.push(objectsToAdd);
currentObjects = newObjects;
}
КС
R
$: objectsById = currentObjects.reduce((items, item) => {
items[item.id] = item;
return items;
}, {});
function onEvent(newObjects) {
let objectsToReplace = {};
let objectsToAdd = [];
for (const obj of newObjects) {
if (items[obj.id]) {
objectsToReplace[obj.id] = obj;
} else {
objectsToAdd.push(obj);
}
}
const newObjects = currentObjects.map((obj) => {
return objectsToReplace[obj.id]
? objectsToReplace[obj.id]
: obj;
});
newObjects.push(objectsToAdd);
currentObjects = newObjects;
}
КС
КС
КС