actionsConfig
Last updated
Last updated
Map of <actionName:config>
which defines the actions you will be able to perform on a resource.
(method) mandatory: (string
) The method of the action. Can be one of: GET
, PATCH
, PUT
, POST
, DELETE
.
(url) mandatory: (string || () : string
) The URL on which the action has to fetch. For dynamic parameters, prefix them with ::
for the resource ID (e.g. ::userId
), and :
for other parameters (e.g. :userType
), and they will get replaced with the urlParams
you will provide (see ).
(cacheHint): ((urlParams, query, body, otherArgs) : object
) A function which will be invoked to generate a cache hint, appended to the formatted URL for caching purpose. It is expected to return an object of serializable values.
(beforeHook): ((urlParams, query, body, otherArgs, dispatch) : undefined || any
) A hook which can be invoked just before performing the request. Will be awaited if async. If it returns a non-falsy value, the return will be used as the body for the principal request.
(normalizer): ((payload, resources, urlParams, query, body, otherArgs) : { entities: normalizedPayload, result: principalResourceId }
) A function which will be invoked to normalize the payload of the request. It is expected to return an object with entities
and result
, respectively containing the normalized payload and the sorted ids, just as does.
(metadataNormalizer): ((payload, resources, urlParams, query, body, otherArgs) : object
) A function which will be invoked to extract metadata from the payload (if any). It is expected to return an object, which will be available via a selector.
(afterHook): ((normalizedPayload, urlParams, query, body, otherArgs, dispatch) : undefined
) A hook which can be invoked after performing the request and normalizing the payload. Will be awaited if async.
(networkHelpers): (map<string|func>
) A map of handlers used when performing network requests. Override the default ones, and the ones specified using initializeNetworkHelpers
. Documentation on the content of the map can be found .
This example demonstrates a sample actionsConfig
.
Returning a promise in a hook will make the execution wait for it to complete before continuing