Gets the entities from the state.
Parameters
reducerSubState
object the part of the state handled by the REST reducer.options
object?= getEntitiesOptionsDefault the options may contain:immutable
(boolean, defaults to true) to define if JS (requires atoJS
conversion) or immutable objects (better for performance) should be returned;reverse
(boolean, defaults to false) to return the objects in reverse order.
Returns oject The entities from the state (immutable list or JS array depending on the configuration).
Gets an entity from the state based on its key.
Parameters
reducerSubState
object the part of the state handled by the REST reducer.key
string the key of the entity to retrieve (the value returned by the specifiedidPath
).options
object?= getEntityOptionsDefault the options to use.immutable
: boolean to specify if the returned object should be immutable (defaults to true).
Returns object The entity (immutable map or JS array depending on the configuration).
Gets the status of the request by status type.
Parameters
reducerSubState
object the part of the state handled by the REST reducer.type
string one offinding
,findingOne
,creating
,updating
ordeleting
.key
string (optional) - the key of the entity (the value returned by the specifiedidPath
).
Returns boolean true
if the request is pending, else false
.
Gets the value within an immutable or JS object.
Parameters
obj
(Iterable | Object | undefined) the immutable or JS object.undefined
is returned if it is not defined.path
(string | [string]) the key(s) to follow. It can be a string , e.g.'slug'
, a path in dot notation, e.g.'profile.slug'
, or an array of strings, e.g.['profile', 'slug']
.
Returns any The value within the object following path, or undefined
if it does not exist.
Creates the handler function to handle the REST request actions (request, success and fail).
Parameters
verb
string The verb to handle (find, findOne, create, update or delete).requestActions
RequestActions An object containing the request, success and fail action creators to handle.idPath
IdPath The path to the value to identify the REST entities (string, string array, function or string with dot seperaing keys).
Returns object An object containing the functions to handle request, success and fail state change in the reducer.
Creates a REST reducer to handle the verbs of the REST action creators.
Parameters
config
object The REST reducer config with the following keys:idPath
, the path to the identifier of the requested objects (string, string array, function or string with dot seperaing keys);actions
: each key of the object is a verb (find, findOne, create, update or delete) and contains the related REST action creators (request, success and fail);extraHandlers
: an object where each key is the action type to handle and each key contains a function to handle the state change for these actions.
Returns Reducer A reducer to handle REST request actions and the extra handlers actions.
Gets the entities from the state.
Parameters
reducerSubState
object the part of the state handled by the REST reducer.options
object?= getEntitiesOptionsDefault the options may contain:immutable
(boolean, defaults to true) to define if JS (requires atoJS
conversion) or immutable objects (better for performance) should be returned;reverse
(boolean, defaults to false) to return the objects in reverse order.
Returns oject The entities from the state (immutable list or JS array depending on the configuration).
Gets an entity from the state.
Parameters
reducerSubState
object the part of the state handled by the REST reducer.key
string the key of the entity to retrieve (the value returned by the specifiedidPath
).options
object?= getEntityOptionsDefault the options to use.immutable
: boolean to specify if the returned object should be immutable (defaults to true).
Returns object The entity (immutable map or JS array depending on the configuration).
Gets the status of the request.
Parameters
reducerSubState
object the part of the state handled by the REST reducer.status
string one offinding
,findingOne
,creating
,updating
ordeleting
.key
string (optional) - the key of the entity (the value returned by the specifiedidPath
).
Returns boolean true
if the request is pending, else false
.
Creates the handler function to handle the REST request actions (request, success, fail).
Parameters
verb
string The verb to handle (find, findOne, create, update or delete).requestActions
RequestActions An object containing the request, success and fail action creators to handle.idPath
IdPath The path to the value to identify the REST entities (string, string array, function or string with dot separation).
Returns object An object containing the functions to handle request, success and fail state change in the reducer.
Creates a REST reducer to handle the defined actions.
Parameters
config
object The REST reducer config with the following keys:idPath
, the path to the identifier of the requested objects (string, array of string or function);actions
: the REST actions to handle;extraHandlers
: an object where each key is the action type to handle and each key contains a function to handle the state change for these actions.
Returns Reducer A reducer to handle REST requests state changes.