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.
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.
Most helpful comment
You'll notice that the parameter passed to
asyncConnectis an array. Each item you want to fetch externally should be an item in that array, for example something like this: