A function that accepts entities and synchronizes the array
const currentItems = [{ id: '1', name: 'Item 1' }];
const syncItems = resolveItemListDeltas({
items: currentItems,
onAddItem: (item) => currentItems.push(item),
onRemoveItem: (id) => {
const index = currentItems.findIndex(i => i.id === id);
if (index >= 0) currentItems.splice(index, 1);
}
});
syncItems(newItems);
Creates a function that synchronizes a plain array of items with new entities. Does not require a container model - works with any array of identifiable items.