-
Notifications
You must be signed in to change notification settings - Fork 194
resolve body with redux state when body is a function #103
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
Conversation
+1 |
+1 what's happening with this? |
I ended up writing my own lib: https://npm.im/redux-api-call |
It's not pretty, but if you want to avoid forking this or using a different library, you can write your own middleware that extends CALL_API. ex: const withStateMiddleware = store => next => action => {
if (CALL_API in action && typeof action[CALL_API].body === 'function') {
return next({
...action,
[CALL_API]: {
...action[CALL_API],
body: action[CALL_API].body(store.getState)
}
});
}
return next(action);
}; Then your body key can just be: body: getState => { ... } Would be nice to get this merged though. |
Hi @tungv, thanks for this and sorry its taken so long to get to 😿 This is pretty interesting functionality. To get this in, we'd need to target this change to the |
similar to get and headers