Modules: collectionActions

Redux actions to manage collections

Source:

Methods


collectionClearAll(collectionId)

Removes all entities from a collection

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

Source:

collectionClearIfContainsRef(collectionId, ref)

Removes all entities from a collection if the given entity is in the collection data

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

ref Object

An { id, type } reference to an entity. If this entity exists in the collection, the collection will be cleared

Source:

collectionClearPagination(collectionId)

Clears all pagination information from a collection

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

Source:

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 atBegin and the atEnd flags to true. Otherwise, this action has no effect.

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

total number

The expected total number of items in the collection

Source:

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 pagination

Parameters:
Name Type Argument Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

refs Array | Object

An array of new { id, type } references to entities

expectedCount number

The number of expected results. If the number of refs is less than this, we know we have reached the end of the list

afterRef Object <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.

assumeAtBegin bool

If true and no afterRef is given, the collection reducer will assume that this is the begin of the list and set atBegin to true. Default to true. When getting deeplinked data (providing a specific cursor to an api call) set this parameter to false

Source:

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 pagination

Parameters:
Name Type Argument Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

refs Array | Object

An array of new { id, type } references to entities

expectedCount number

The number of expected results. If the number of refs is less than this, we know we have reached the start of the list

beforeRef Object <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.

Source:

collectionRemoveRefs(collectionId, refs)

Removes the given entities from a collection

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

refs Array

An array of new { id, type } references that should be removed

Source:

collectionReplace(collectionId, refs)

Replaces all the entities in a collection

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

refs Array

An array of new { id, type } references to entities

Source:

collectionSetAtOffset(collectionId, refs [, offset])

Replaces the entities at the given offset with the given refs.

Parameters:
Name Type Argument Default Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

refs Array

An array of new { id, type } references to entities

offset number <optional>
0

The offset in the collection at which to start replacing

Source:

collectionSetTotal(collectionId, total)

Sets the total field of a collection's pagination. 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
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

total number

The new total

Source:

collectionUnshift(collectionId, refs)

Adds the given entities to the start of the collection, before all other entries.

Parameters:
Name Type Description
collectionId string

The id of the collection to update. Should be obtained from module:collectionIds

refs Array | Object

An array of new { id, type } references to entities

Source: