Commit c2511034 authored by Alexander Kotov's avatar Alexander Kotov

add redux-thunk and clear history on new game

parent 0337167c
......@@ -9018,6 +9018,11 @@
"symbol-observable": "^1.2.0"
}
},
"redux-thunk": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz",
"integrity": "sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw=="
},
"redux-undo": {
"version": "1.0.0-beta9-9-7",
"resolved": "https://registry.npmjs.org/redux-undo/-/redux-undo-1.0.0-beta9-9-7.tgz",
......
......@@ -8,6 +8,7 @@
"react-redux": "^5.0.7",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"redux-undo": "^1.0.0-beta9-9-7"
},
"scripts": {
......
import { ActionCreators } from 'redux-undo'
import { START_NEW_GAME } from "./types";
export const startNewGame = (options) => ({
type: START_NEW_GAME,
payload: options
})
export const startNewGame = (options) => (dispatch) => {
dispatch({
type: START_NEW_GAME,
payload: options
})
dispatch(ActionCreators.clearHistory())
}
import { createStore } from 'redux'
import { createStore, compose, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import rootReducer from './reducers'
const store = createStore(
rootReducer,
localStorage.state && JSON.parse(localStorage.state),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
compose(
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
)
store.subscribe(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment