diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-07-22 14:05:15 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-07-22 14:05:15 +0200 |
| commit | ef78bc6a084f92b4794e987b5832240d85b6479e (patch) | |
| tree | b314b630800db6aa60f28ef0b115625e6ca176db /animism-align/frontend/app/store.js | |
| parent | 85d4cb9addf9ca887d3440b2786665d67d9917c4 (diff) | |
refactor app using babel module-resolver
Diffstat (limited to 'animism-align/frontend/app/store.js')
| -rw-r--r-- | animism-align/frontend/app/store.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/animism-align/frontend/app/store.js b/animism-align/frontend/app/store.js new file mode 100644 index 0000000..e779ce4 --- /dev/null +++ b/animism-align/frontend/app/store.js @@ -0,0 +1,52 @@ +import { applyMiddleware, compose, combineReducers, createStore } from 'redux' +import { connectRouter, routerMiddleware } from 'connected-react-router' +import { createBrowserHistory } from 'history' +// import createDebounce from 'redux-debounced' +import thunk from 'redux-thunk' +// import { login } from 'app/utils' + +import uploadReducer from 'app/views/upload/upload.reducer' +import alignReducer from 'app/views/align/align.reducer' +import audioReducer from 'app/views/audio/audio.reducer' +import paragraphReducer from 'app/views/paragraph/paragraph.reducer' +import annotationReducer from 'app/views/annotation/annotation.reducer' +import siteReducer from 'app/views/site/site.reducer' +import mediaReducer from 'app/views/media/media.reducer' + +const createRootReducer = history => ( + combineReducers({ + auth: (state = {}) => state, + router: connectRouter(history), + site: siteReducer, + upload: uploadReducer, + align: alignReducer, + audio: audioReducer, + paragraph: paragraphReducer, + annotation: annotationReducer, + media: mediaReducer, + }) +) + +const configureStore = (initialState = {}, history) => { + const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose + + const store = createStore( + createRootReducer(history), + initialState, + composeEnhancers( + applyMiddleware( + thunk, + // createDebounce(), + routerMiddleware(history) + ), + ), + ) + + return store +} + +const history = createBrowserHistory() +const store = configureStore({}, history) +const { dispatch } = store + +export { store, history, dispatch } |
