Skip to content

Conversation

tungv
Copy link

@tungv tungv commented Sep 15, 2016

similar to get and headers

@coveralls
Copy link

coveralls commented Sep 15, 2016

Coverage Status

Coverage decreased (-0.6%) to 99.39% when pulling 4c98205 on tungv:master into e72ac27 on agraboso:master.

@coveralls
Copy link

coveralls commented Sep 15, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 8db491c on tungv:master into e72ac27 on agraboso:master.

@luisincrespo
Copy link

+1

@IanLondon
Copy link

+1 what's happening with this?

@tungv
Copy link
Author

tungv commented Mar 8, 2017

I ended up writing my own lib: https://npm.im/redux-api-call

@ztanner
Copy link
Contributor

ztanner commented Jul 31, 2017

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.

@nason
Copy link
Collaborator

nason commented Sep 21, 2017

Hi @tungv, thanks for this and sorry its taken so long to get to 😿

This is pretty interesting functionality. master is currently the 1.0 branch, and we're working on 2.0 in next.

To get this in, we'd need to target this change to the next branch. Do you still want to help? I might be able to work on this in a couple days otherwise.

nason added a commit that referenced this pull request Jan 24, 2018
This is #103, rebased and updated to be compatible with 2.x

h/t @tungv
@nason
Copy link
Collaborator

nason commented Jan 24, 2018

Hi @tungv I went ahead and ported this change over to 2.x in #168

Thank you!

@nason nason closed this Jan 24, 2018
nason added a commit that referenced this pull request Jan 24, 2018
This is #103, rebased and updated to be compatible with 2.x

h/t @tungv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants