React-redux-universal-hot-example: How to call Multiple Async Calls on Containers?

Created on 22 May 2016  路  2Comments  路  Source: erikras/react-redux-universal-hot-example

Apologies, for this is not an Issue but query about understanding the React Redux.

Consider the below scenario

/**
 * Created by comp on 4/13/2016.
 */
import React, {Component, PropTypes} from 'react';
import { asyncConnect } from 'redux-async-connect';
import {load, setActiveOrderIndex } from 'redux/modules/dashboard';
import {load as loadOrders} from 'redux/modules/orderpreview';
import * as panelActions from 'redux/modules/panelresizer';
import {connect} from 'react-redux';

@asyncConnect([{
  deferred: true,
  promise: ({store: {dispatch}}) => {
    return dispatch(load());
  }
}])

I am able to make a async call. but how do I call multiple dispatch?
For example, I want to load list of users and list of cities via Async calls.

TIA.

Most helpful comment

You'll notice that the parameter passed to asyncConnect is an array. Each item you want to fetch externally should be an item in that array, for example something like this:

@asyncConnect([{
  deferred: true,
  promise: ({store: {dispatch}}) => {
    return dispatch(loadUsers());
  }
}, {
  deferred: true,
  promise: ({store: {dispatch}}) => {
    return dispatch(loadCities());
  }
}])

All 2 comments

You'll notice that the parameter passed to asyncConnect is an array. Each item you want to fetch externally should be an item in that array, for example something like this:

@asyncConnect([{
  deferred: true,
  promise: ({store: {dispatch}}) => {
    return dispatch(loadUsers());
  }
}, {
  deferred: true,
  promise: ({store: {dispatch}}) => {
    return dispatch(loadCities());
  }
}])

That solution works. Cursing myself how i missed it.. Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

korczis picture korczis  路  3Comments

yesmeck picture yesmeck  路  3Comments

LarryEitel picture LarryEitel  路  4Comments

glennr picture glennr  路  6Comments

krishnasaga picture krishnasaga  路  3Comments