redux-landing
v1.0.1
Published
Initialize redux state asynchronously with multiple async actions.
Downloads
5
Readme
Initialize redux state asynchronously with multiple async actions.
Install
npm install --save redux-landing
Usage
import { createStore, applyMiddleware } from "redux";
import landing from "redux-landing";
import thunk from "redux-thunk";
import customizedMiddleware from "./middlewares/customized";
import rootReducers from "./reducers";
import { action1, action2, actionN } from "./actions";
const middlewares = [thunk, customizedMiddleware];
const initActions = [
action1(params),
action2(params),
actionN(params)
];
const asyncDispatch = landing(rootReducers, ...middlewares);
asyncDispatch(...initActions).then((preloadedState) => {
const enhancer = applyMiddleware(...middlewares);
const store = createStore(rootReducers, preloadedState, enhancer);
});