actionTypes
An object of Redux action types that the resource reducer responds to. Dispatch these from action creators to change the state of your store.
The complete object is shown below:
Notes
The action types can be organized into two groups:
Direct manipulation of the store.
UPDATE_RESOURCES
andDELETE_RESOURCES
allow you to synchronously modify the store, independent of requests.The rest of the action types are for requests. Within the request action types, there are four groups of action types, one for each of the four CRUD actions. Within each CRUD action "group," the four action types reflect the four request statuses.
Reserved Action Types
An upcoming version of Redux Resource will utilize four new action types to simplify the request action types. Accordingly, these action types have been reserved, and we do not recommend that you use them in your application. The list of reserved action types is:
Note: A warning will be logged to the console if you dispatch an action with one of these action types in your application.
Example
This example shows an action creator that reads a single book. It uses the redux-thunk middleware and the library xhr for making requests.
Tips
The
{crudAction}_RESOURCES_IDLE
action type is useful anytime that you want to "reset" the status of a request. One use case for this is when a request is aborted. Another use case would be for an alert that displays whenever a request is in a failed state. When the user dismisses the alert, you might trigger this action type to 'reset' the request status back toIDLE
, which would then hide the alert.You may not always use this action type, and that's fine. But it's here if you do need it.
Last updated