Members
-
<static, constant> GET_NEXT :Symbol
-
Can be passed as a value for
offsetinapiGetCollectionto automatically get the next set we don't have yetType:
- Symbol
-
<static, constant> GET_PREVIOUS :Symbol
-
Can be passed as a value for
offsetinapiGetCollectionto automatically get the previous set we don't have yetType:
- Symbol
-
<static, constant> IDENTITY_TRANSFORM :function
-
Default transform for the api response. Leaves the data untouched
Type:
- function
Methods
-
apiGetCollection(actionType, gatewayType, path, collectionId [, paginationOptions] [, options])
-
Performs an API request to get a list of entities.
Parameters:
Name Type Argument Description actionTypestring The
typeproperty of the dispatched api request action is set to this valuegatewayTypestring The type of gateway to use. These should be one of the strings defined in
module:Injectablespathstring The path to the endpoint to request
collectionIdstring The ID of the collection to store the data in. Should be obtained from
module:collectionIdspaginationOptionsGetCollectionPaginationOptions <optional>
Object that contains optional pagination options
optionsobject <optional>
Object with optional options
Properties
Name Type Argument Default Description requestDataobject <optional>
null Object with data to send with the API request. This is merged with any parameters that result from paginationOptions.
requestOptionsobject <optional>
{} Object with additional options passed to the gateway. Please see gateway documentation for more info
transformResponsefunction <optional>
A function that will transform the response before it is processed
entityTypestring | function <optional>
entity => entity._type A string that indicates type of entities we expect to retrieve from the API. Can also be a function, that takes a responded entity and returns the type of that entity.
getIdfunction <optional>
entity => entity.id A function that returns the id for each entity returned from the api. Defaults to reading from the
idproperty on the entity object.storeEntitiesfunction <optional>
true If
false, will not store entities to the entities reducer, but only references to the collection reducer. This is useful when the API returns references only, with no data attached.cachingGetCollectionCachingCallback | false <optional>
A function that manages caching for this request or
falseto always make a full request. SeeGetCollectionCachingCallbackupdatePaginationViewstring | object <optional>
If set, will update a
collectionPaginationViewReducerto match thepaginationOptionspassed to this action. Can be a string id of thecollectionPaginationViewReducer, or an object with the following properties:targetID of thecollectionPaginationViewReducerextendIf true, will extend the current pagination instead of replacing it. This can be used when doing infinite-scroll type pagination instead of offset-based.
Returns:
A Promise that resolves with the entity data
- Type
- Promise
-
collectionCachingDefault(paginationOptions, currentCollectionState, requestData, getState, path)
-
Default caching for
apiGetCollection. Will lookup the requested items in the current collection reducer state. When some items already exist, will truncate the request pagination parameters to not include these items. When all items already exist, will cancel the call.Parameters:
Name Type Description paginationOptionsGetCollectionPaginationOptions The pagination options passed to
apiGetCollectioncurrentCollectionStateobject The state of the
collectionReducer. If no state is currently present, this will beundefinedrequestDataobject The requestData argument of
apiGetCollectiongetStatefunction The redux getState function
pathstring The api request path. Used for debug logs
Returns:
The paginationOptions parameter modified for caching
-
collectionCachingNoPagination(paginationOptions [, currentCollectionState])
-
Simplified caching for
apiGetCollection. If any data is present in the current collection state, we consider the list as cached (regardless of the amount of data).Parameters:
Name Type Argument Description paginationOptionsobject The pagination options passed to
apiGetCollectioncurrentCollectionStateobject <optional>
The state of the
collectionReducer. If no state is currently present, this will beundefinedReturns:
The paginationOptions parameter modified for caching or false if data was already present
- Type
- object | boolean
-
processApiGetCollectionResponse(response, actionType, gatewayType, path, collectionId, paginationOptions, options)
-
This action will call
apiGetCollection, but will leave out doing an API request. Instead, you should provide the response of the request as the first argument to this function. All other arguments are the same asapiGetCollectionThis action can be used when we already have some response data, but we still want to make use of the apiGetCollection functionality to process that data.Parameters:
Name Type Description responseobject An object that is the same shape as a response that would come from a collection api call
actionTypestring see
apiGetCollectiongatewayTypestring see
apiGetCollectionpathstring see
apiGetCollectioncollectionIdstring see
apiGetCollectionpaginationOptionsobject see
apiGetCollectionoptionsobject see
apiGetCollection