A Reasonable complete task for http request, such as loading, success, error, cancel and retry handler. Created by redux-obervable and rxjs.
A lazy utils request method for get, post, patch, put, and delete.
Please check the documentation here.
yarn add rxjs-agile-request
import your methods in request.
import {
getRequest,
postRequest,
patchReuqest,
putReuqest,
deleteRequest,
} from 'rxjs-agile-request';
const getBlogUrl = `${jsonplacehoder}/posts21`;
export const getBlogEpic = action$ =>
action$.ofType(TYPES.GET_BLOG_EPIC).switchMap(() => {
const loading = ACTION.getBlogLoading();
const success = ACTION.getBlogSuccess;
const cancel = ACTION.getBlogCancel
const error = ACTION.getBlogError;
const ObjectActions = {
url: getBlogUrl,
headers,
loading,
success,
cancel,
error,
retry: error => {
return 404 === error.status;
},
};
return getRequest(ObjectActions);
});
Actions | TYPE | DESCRIPTION |
---|---|---|
loading | required | return boolean |
success | required | return object |
error | required | return object |
cancel | optional | return nothing just is this action to componentWillUnmount |
retry | optional | is a function that as a callback of object of error, it must return a boolean so the agileRequest wil know where to retry |
Main contributors:
- Justin Lazaro (juztinlazaro)
- Chelzea Louise Salvador (chlzslvdr) - documentations
- Nicho Guimbaolibot (nichoguimbaolibot) - for the project name.