redux-resource
redux-resource copied to clipboard
redux-resource-fetch
Assuming #275 isn't closed in favor of #250, I should figure out the API for redux-resource-fetch, making the assumption that AbortController is supported.
The popular GitHub fetch polyfill may soon support this: https://github.com/github/fetch/issues/547
One possibility based on #275 :
// There is now only one method!
// The first argument determines which CRUD action it is
crudRequest('read', {
url: '/pasta/pls',
// These are options to configure the XHR request
fetchOptions: {
credentials: 'include',
signal: abortController.signal
},
// These are properties that are merged into the start and end action by default
actionProperties: {
resourceName: 'books',
mergeMeta: false
},
// same as what exists today
transformData(data) {
return body.data;
}
})
.then(
(action, body) => dispatch(action)
(action, err) => dispatch(action)
);
I'm going to close this as revisit. I'll open it when/if the abort polyfill lands.