Redux actions to manage collections
Methods
-
collectionClearAll(collectionId)
-
Removes all entities from a collection
Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIds -
collectionClearIfContainsRef(collectionId, ref)
-
Removes all entities from a collection if the given entity is in the collection data
Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefObject An
{ id, type }reference to an entity. If this entity exists in the collection, the collection will be cleared -
collectionClearPagination(collectionId)
-
Clears all pagination information from a collection
Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIds -
collectionPartitionCheckComplete(collectionId, total)
-
Checks if a partition collection is 'complete'. That is, the number of entities in the collection is as big as the given total. In that case, this action will set both the
atBeginand theatEndflags totrue. Otherwise, this action has no effect.Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdstotalnumber The expected total number of items in the collection
-
collectionPartitionSetAfter(collectionId, refs, expectedCount [, afterRef], assumeAtBegin)
-
Adds the given entities to collection after all other entries. To be used for collections with pagination type
PAGINATION_PARTITION. This is usually for cursor-based paginationParameters:
Name Type Argument Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefsArray | Object An array of new
{ id, type }references to entitiesexpectedCountnumber The number of expected results. If the number of refs is less than this, we know we have reached the end of the list
afterRefObject <optional>
An
{ id, type }pair of the ref after which these refs should be inserted. If omitted it is assumed that the current state refs should be replaced. If given, but the ref does not exist in the current state, this action will be ignored.assumeAtBeginbool If
trueand no afterRef is given, the collection reducer will assume that this is the begin of the list and setatBegintotrue. Default totrue. When getting deeplinked data (providing a specific cursor to an api call) set this parameter tofalse -
collectionPartitionSetBefore(collectionId, refs, expectedCount [, beforeRef])
-
Adds the given entities to collection before all other entries. To be used for collections with pagination type
PAGINATION_PARTITION. This is usually for cursor-based paginationParameters:
Name Type Argument Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefsArray | Object An array of new
{ id, type }references to entitiesexpectedCountnumber The number of expected results. If the number of refs is less than this, we know we have reached the start of the list
beforeRefObject <optional>
An
{ id, type }pair of the ref before which these refs should be inserted. If omitted it is assumed that the current state refs should be replaced. If given, but the ref does not exist in the current state, this action will be ignored. -
collectionRemoveRefs(collectionId, refs)
-
Removes the given entities from a collection
Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefsArray An array of new
{ id, type }references that should be removed -
collectionReplace(collectionId, refs)
-
Replaces all the entities in a collection
Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefsArray An array of new
{ id, type }references to entities -
collectionSetAtOffset(collectionId, refs [, offset])
-
Replaces the entities at the given
offsetwith the givenrefs.Parameters:
Name Type Argument Default Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefsArray An array of new
{ id, type }references to entitiesoffsetnumber <optional>
0 The offset in the collection at which to start replacing
-
collectionSetTotal(collectionId, total)
-
Sets the
totalfield of a collection'spagination. This should be set to the total items available on the server and does not necessarily equal the total items currently in state.Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdstotalnumber The new total
-
collectionUnshift(collectionId, refs)
-
Adds the given entities to the start of the collection, before all other entries.
Parameters:
Name Type Description collectionIdstring The id of the collection to update. Should be obtained from
module:collectionIdsrefsArray | Object An array of new
{ id, type }references to entities