actions.md

May 10, 2018 ยท View on GitHub

Actions

In redux, actions are sent with a payload which triggers a reducer function which modifies the state depending on the action type and the payload.

The following actions are used in NgrxJsonApi:

Action TypeDescription
API_CREATE_INITIssues a POST request for a resource.
API_CREATE_SUCCESSUpon success completion of a POST request.
API_CREATE_FAILUpon a failure of a POST request.
API_GET_INITIssues a GET request for a resource.
API_GET_SUCCESSUpon success completion of a GET request.
API_GET_FAILUpon a failure of a GET request.
API_UPDATE_INITIssues a PATCH request for a resource.
API_UPDATE_SUCCESSUpon success completion of a PATCH request.
API_UPDATE_FAILUpon a failure of a PATCH request.
API_DELETE_INITIssues a DELETE request for a resource.
API_DELETE_SUCCESSUpon success completion of a DELETE request.
API_DELETE_FAILUpon a failure of a DELETE request.
API_APPLY_INITInitiates the appropriate API_X_INIT action for all pending local modifications except resources in state NEW.
API_APPLY_SUCCESSUpon success completion of all requested modifications.
API_APPLY_FAILUpon failure a at least one requested modification.
API_ROLLBACK:Reverts all local changes to resources in the store.
API_QUERY_REFRESHUpdates the result of a query by initiating a API_READ_INIT.
LOCAL_QUERY_INITSets up a query that is run locally based on the contents of the store.
LOCAL_QUERY_SUCCESSTriggered when a local query was successfully updated in the store.
LOCAL_QUERY_FAILTriggered when a local query failed.
DELETE_STORE_RESOURCEMarks a resource in the store for deletion. Does not trigger an update to the server.
PATCH_STORE_RESOURCEPatches a resource in the store by merging the provided values with the ones from the store. Does not trigger an update to the server.
POST_STORE_RESOURCEAdds a new resource to the store. Does not trigger an update to the server. The resource then carries the state CREATED.
NEW_STORE_RESOURCEAdds a new resource to the store that is not yet considered being ready to be posted to the server. The resource then carries the state NEW rather than CREATED.
MODIFY_STORE_RESOURCE_ERRORSModifies the errors of a resource in the store. Use for client side validation.
REMOVE_QUERYRemoves a query from the store.
COMPACT_STORERemoves all resources from the store that are not directly or indirectly (relationships) references from a query
CLEAR_STORERemoves all the contents from the store

More information are available in actions.ts.