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

Hanging forever on await res.text() in react native #103

Closed
Noitidart opened this issue Aug 1, 2017 · 4 comments
Closed

Hanging forever on await res.text() in react native #103

Noitidart opened this issue Aug 1, 2017 · 4 comments

Comments

@Noitidart
Copy link

I am using redux thunk.

function push() {
    return (dispatch, getState) => {

        ////// start first dispatch
        dispatch({
            type: 'PUSH',
        })
        ////// start first dispatch

        ////// start second dispatch
        dispatch(apiCall(id));
        ////// end second dispatch
    }
}

function apiCall() {
    return (dispatch, getState) => {
        // this is really where second dispatch happens
        dispatch({
            type: 'API_CALL',
            meta: {
                offline: {
                    effect: getEffect(),
                    commit: { type:'API_DONE' },
                    rollback: { type:'API_FAIL' }
                }
            }
        })
        // end really dispatch second
    }
}

I tried it without thunk's too. It is not firing multiple times, it doesnt fire at all. It gets to the dispatch((0, _actions.busy)(true)); but the promise never resolves or errors:

  return config.effect(metadata.effect, action).then(function (result) {
    console.log('config.effect result:', result);
    return dispatch(complete(metadata.commit, true, result));
  }).catch(function (error) {
    console.error('config.effect gave error:', error);
    // discard
    if (config.discard(error, action, retries)) {
      console.log('Discarding action', action.type);
      return dispatch(complete(metadata.rollback, false, error));
    }
@Noitidart
Copy link
Author

It seems to hang forever on return getResponseBody in defaults/effect

@Noitidart
Copy link
Author

I'm using React Native by the way

@Noitidart Noitidart changed the title Dispatching multiple times with thunks not working in initial action Hanging forever on await res.text() in react native Aug 1, 2017
@patilrevansidh
Copy link

@Noitidart I want to understand working with config and its commit, rollback dispatch can you please provide your complete code sample

@Noitidart
Copy link
Author

@patilrevansidh I actually had done this work for a company, I don't have access to it, and I actually forgot now how I did it. :(

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

2 participants