Created
May 4, 2020 09:50
-
-
Save EnetoJara/6745b8c9d36a3febcffebbd540a27f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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