-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC #79
Comments
c6b2eb0 JWT authorization |
Performing multiple calls to the same endpoint may also be a useful case. I've documented my approach here, for anyone interested: https://gist.github.com/wvengen/39b561607691e33bc0db050264ebc1e7 |
@wvengen very good example. Would you like to move you example to |
@wvengen // a basic redux-api rest store
import reduxApi from 'redux-api';
import adapterFetch from "redux-api/lib/adapters/fetch";
export default ReduxApi({
productCategories: {
url: '/api/v1/products/categories',
postfetch: [
function({data, actions, dispatch, getState, request}) {
if (!data) { return [];}
const { categories } = data;
if (!categories) { return [];}
const requests = categories.map(({id}) => {
const requestParams = { .... };
return actions.productHistogram.request(requestParams);
});
// It very interesting place, maybe postfetch should process Promise
// This allow save all products information in categories
Promise.all(requests).then((data)=> {
dispatch({ type: "PRODUCTS_UPTATES", data })
});
}
]
},
productHistogram: {
url: '/api/v1/products/histogram',
virtual: true,
transformer: (data) => (data || {}).products_histogram,
},
}).use('fetch', adapterFetch(fetch)); |
My typical use-case includes chaining update and fetching a full list after the update. I can achieve this currently with helpers but having something like postfetch that would delay resolving the original action would simplify the code a lot. I have "list" and "update" actions separately and currently I need to have the "updateAndFetchList" helper under the "list", which makes it a bit confusing. Currently postfetch is not blocking the resolution of the original action and thus there is a small race condition between update and list being refetched. I have considered using one reducer but then I lose being able to separate "what" is loading / having error. |
Hi @mkoppanen can you create new issue with example of you code. I'll try to help you. |
Typical cases.
Feature requests.
The text was updated successfully, but these errors were encountered: