summaryrefslogtreecommitdiff
path: root/frontend/src/reducers.js
diff options
context:
space:
mode:
authorVictor Chabbert <chabbertvi@eisti.eu>2017-01-22 18:34:14 +0100
committerVictor Chabbert <chabbertvi@eisti.eu>2017-01-22 19:28:49 +0100
commit0c9e9480471848a4b8670da22b609535cb153ff3 (patch)
treee59256cb6e8ec6b1041db8ed9902f89e4c39d2e2 /frontend/src/reducers.js
parentAdd notification for updated game to /topics/games (diff)
downloadseven-wonders-0c9e9480471848a4b8670da22b609535cb153ff3.tar.gz
seven-wonders-0c9e9480471848a4b8670da22b609535cb153ff3.tar.bz2
seven-wonders-0c9e9480471848a4b8670da22b609535cb153ff3.zip
Made redux store fully immutable
Diffstat (limited to 'frontend/src/reducers.js')
-rw-r--r--frontend/src/reducers.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/frontend/src/reducers.js b/frontend/src/reducers.js
index 9befff13..097f9243 100644
--- a/frontend/src/reducers.js
+++ b/frontend/src/reducers.js
@@ -1,5 +1,20 @@
-import { combineReducers } from 'redux'
-import { routerReducer } from 'react-router-redux'
+import { combineReducers } from 'redux-immutable'
+
+// react-router-redux immutable reducer
+import { fromJS } from 'immutable'
+import { LOCATION_CHANGE } from 'react-router-redux'
+
+const initialState = fromJS({
+ locationBeforeTransitions: null
+})
+
+const routerImmutableReducer = (state = initialState, action) => {
+ if (action.type === LOCATION_CHANGE) {
+ return state.set('locationBeforeTransitions', action.payload)
+ }
+
+ return state
+}
import gamesReducer from './redux/games'
import playersReducer from './redux/players'
@@ -7,7 +22,7 @@ import playersReducer from './redux/players'
export default function createReducer() {
return combineReducers({
games: gamesReducer,
- routing: routerReducer,
+ routing: routerImmutableReducer,
players: playersReducer,
})
}
bgstack15