selectors
To access state data and metadata, redux-rest-easy
provides useful selectors. Creating a resource with createResource will return an object containing a selectors
key, containing the following selectors:
Resource
Available to any connected component.
getResource(state, applyDenormalizer = true)
: array<object>
getResource(state, applyDenormalizer = true)
: array<object>
Will return the whole resource (or an empty array). Will be denormalized by default, but can be overridden.
getResourceById(state, id, applyDenormalizer = true)
: object
getResourceById(state, id, applyDenormalizer = true)
: object
Will return the object corresponding to the id passed as a parameter (or null). Will be denormalized by default, but can be overridden.
Action.resource
Available to any connected component.
couldPerform(state)
: bool
couldPerform(state)
: bool
isPerforming(state)
: bool
isPerforming(state)
: bool
hasSucceeded(state)
: bool
hasSucceeded(state)
: bool
hasFailed(state)
: bool
hasFailed(state)
: bool
isValid(state)
: bool
isValid(state)
: bool
Will return true
if the action could perform / is performing / has succeeded / has failed on this resource, or if the resource is valid.
couldPerformOnId(state, id)
: bool
couldPerformOnId(state, id)
: bool
isPerformingOnId(state, id)
: bool
isPerformingOnId(state, id)
: bool
hasSucceededOnId(state, id)
: bool
hasSucceededOnId(state, id)
: bool
hasFailedOnId(state, id)
: bool
hasFailedOnId(state, id)
: bool
isValidId(state, id)
: bool
isValidId(state, id)
: bool
Will return true
if the action could perform / is performing / has succeeded / has failed on this resource id, or if the resource id is valid.
Action.request
Only available to connected components which specifically requested a resource (via dispatch). They will need to pass ownProps as an argument, on top of state.
getResource(state, ownProps, applyDenormalizer = true)
: array<object>
getResource(state, ownProps, applyDenormalizer = true)
: array<object>
Will return the resource corresponding to the payload of the request (or an empty array). Will be denormalized by default, but can be overridden.
getMetadata(state, ownProps)
: object
getMetadata(state, ownProps)
: object
Will return the metadata corresponding to the payload of the request (or an empty object).
couldPerform(state, ownProps)
: bool
couldPerform(state, ownProps)
: bool
isPerforming(state, ownProps)
: bool
isPerforming(state, ownProps)
: bool
hasSucceeded(state, ownProps)
: bool
hasSucceeded(state, ownProps)
: bool
hasFailed(state, ownProps)
: bool
hasFailed(state, ownProps)
: bool
isValid(state, ownProps)
: bool
isValid(state, ownProps)
: bool
Will return true
if the request (dispatched by the component) could perform / is performing / has succeeded / has failed, or if the associated request is valid.
Last updated