Skip to content
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

Multiple requests get resolved with the first one which succeeds #13

Open
stefanfrede opened this issue Sep 20, 2018 · 3 comments
Open

Comments

@stefanfrede
Copy link
Contributor

If I fire up multiple requests where each request takes some time before it gets resolved all requests are getting resolved with the first request which succeeds.

async getUser(request) {
  return new Promise(resolve => {
    const generatedAsyncFunction = promiseListener.generateAsyncFunction({
      start: 'START_ACTION_TYPE',
      resolve: 'RESOLVE_ACTION_TYPE',
      reject: 'REJECT_ACTION_TYPE'
    });

    generatedAsyncFunction.asyncFunction({ request }).then(
      resolvePayload => {
        resolve(resolvePayload);
      },

      rejectPayload => {
        resolve(rejectPayload);
      }
    )
  });
};

// All requests are getting resolved with A
getUser('A').then(console.log);
getUser('B').then(console.log);
getUser('C').then(console.log);
@mattoni
Copy link

mattoni commented Nov 21, 2018

I also am running into this issue. Would be good if we could pass a conditional to resolve based on the payload (i.e. an ID has to match the id that was in the original action)

@chmanie
Copy link

chmanie commented Jan 15, 2019

I am working on something like this. Given the little activity here I am considering to release the fork as a separate package on npm. Did the author move on to something else?

@chmanie
Copy link

chmanie commented Jan 15, 2019

Take a look at this fork:
JoinColony@db4175d

This maintains compatibility to the current usage of this module.

What you will have to do is passing through the meta property in your sagas if in the cases where you need it (there’s just no way around that), like in this module (which does a similar thing):
https://github.com/diegohaz/redux-saga-thunk#usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants