All functions in this module are action creators and the return value should be passed to the redux store dispatch() function.
Methods
-
addEntities(entities)
-
Add an object of new entities
Parameters:
Name Type Description entitiesobject An object containing new entities. This object should be structured as a map by entity type and then by entity id, like so: { [entityType]: { [entityId]: {
}, ... } ... } -
addEntitiesOfType(entities, entityType)
-
Add an object of new entities that all have the same type.
Parameters:
Name Type Description entitiesobject An object containing new entities. The keys of the object are the ids for the entities. The values are the entities themselves. This will overwrite any existing entities in the reducer for that entity type.
entityTypestring The entity type of the given entities.
-
removeEntities(ids, entityType)
-
Removes entities from the entity reducer
Parameters:
Name Type Description idsArray The ids of the entities to remove
entityTypestring The type of the entities to remove
-
setEntity(entityType, enitityId, data [, merge])
-
Sets the data for a single entity. If the entity does not exist, it will be created.
Parameters:
Name Type Argument Default Description entityTypestring The type of entity
enitityIdstring The id of the entity
dataobject The data to set
mergeboolean | function <optional>
false Indicates if existing data should be replaced or merged. By default, existing data will be replaced. If merge is true, existing and new data will be merged by a simple Object.assign(). merge may also be a function that takes the old and new data, and returns a merge result.
-
updateEntities(entityType, data [, predicate])
-
Updates one or more entities by merging the given data into the entities
note: all matching entities will update to a new object reference, even if the new data is the same as the current data. For performance reasons, make sure not to match more entities than necessary.
Parameters:
Name Type Argument Description entityTypestring The type of the entity to update
dataobject The data to merge into the matched entities
predicateobject <optional>
An object with properties that should match the entities to update (strict equality). If not given, will update all entities of the given type