Skip to content

Instantly share code, notes, and snippets.

@EnetoJara
Created May 4, 2020 09:50
Show Gist options
  • Save EnetoJara/6745b8c9d36a3febcffebbd540a27f72 to your computer and use it in GitHub Desktop.
Save EnetoJara/6745b8c9d36a3febcffebbd540a27f72 to your computer and use it in GitHub Desktop.
import { applyMiddleware, createStore } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import createSagaMiddleware from "redux-saga";
import { rootReducer } from "../reducers";
import { AppState } from "@eneto/api-client";
import { initUserState } from "../../modules/users/user-reducer";
import { initUsersState } from "../../modules/users/users-reducer";
import { initListsState } from "../../modules/lists/lists-reducer";
import { initListState } from "../../modules/lists/list-reducer";
// initialValues
const init: AppState = {
currentUser: initUserState,
users: initUsersState,
lists: initListsState,
currentList: initListState
};
export function store(initialState: AppState = init) {
const sagaMiddleware = createSagaMiddleware();
const middleware = [sagaMiddleware];
return {
...createStore(rootReducer, initialState, composeWithDevTools(applyMiddleware(...middleware))),
runSaga: sagaMiddleware.run
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment