mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-04 23:43:51 +03:00
29 lines
611 B
JavaScript
29 lines
611 B
JavaScript
var createStore = require('redux').createStore;
|
|
var devTools = require('remote-redux-devtools').default;
|
|
|
|
function counter(state, action) {
|
|
if (state === undefined) state = 0;
|
|
switch (action.type) {
|
|
case 'INCREMENT':
|
|
return state + 1;
|
|
case 'DECREMENT':
|
|
return state - 1;
|
|
default:
|
|
return state;
|
|
}
|
|
}
|
|
|
|
var store = createStore(counter, devTools({ realtime: true }));
|
|
store.subscribe(function () {
|
|
console.log(store.getState());
|
|
});
|
|
|
|
function incrementer() {
|
|
setTimeout(function () {
|
|
store.dispatch({ type: 'INCREMENT' });
|
|
incrementer();
|
|
}, 1000);
|
|
}
|
|
|
|
incrementer();
|