making this cleaner with composeWithDevTool

This commit is contained in:
Ken
2019-02-24 14:16:30 -08:00
parent c310f3a8b1
commit 1e609dd408
9 changed files with 34 additions and 78 deletions

View File

@@ -1,19 +1,18 @@
import { reducer } from './reducers';
import { createStore, compose } from 'redux';
import { createStore } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import { actions } from './actions';
/* Goop for making the Redux dev tool to work */
declare var window: any;
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
function createStoreWithDevTool(reducer, initialStore) {
return createStore(reducer, initialStore, composeEnhancers());
}
const store = createStoreWithDevTool(reducer, {});
const store = createStore(reducer, {}, composeWithDevTools());
console.log(store.getState());
store.dispatch(actions.addTodo('hello'));
store.dispatch(actions.addTodo('world'));
/*
TODO: dispatch several actions and see the effect to the state inside the Redux devtool
store.dispatch(actions.???);
store.dispatch(actions.???);
store.dispatch(actions.???);
*/
console.log(store.getState());