entity, update many, ... • remove entity, remove many, ... • read speci fi c entity, fi nd entities matching a condition, ... Operations on Collections
want to add const newItem: Entity = { id: 'itemId', ... }; // simply appending to the end collection = collection.concat(newItem); collection = [...collection, newItem]; // beware of duplicates + order Adding to the collection (array)
are trying to find const target = 'itemId'; // find in the collection const item: Entity | undefined = collection.find(item => item.id === target); // worst case: iterates whole list without a match Read an item from the collection (array) by id
many entities ef fi ciently • provides methods and selectors to manage a collection immutably • agnostic, can be used in many contexts (Store, ComponentStore) → reduces boilerplate / repetition → keeps reducers small What is the EntityAdapter?