mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
IMPR: Redux compatibilities
This commit is contained in:
parent
1404ea8ff9
commit
cdb64dbddd
5
src/js/store/components/index.js
Normal file
5
src/js/store/components/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import PageControls from './page-controls';
|
||||||
|
|
||||||
|
export {
|
||||||
|
PageControls,
|
||||||
|
};
|
6
src/js/store/components/page-controls.js
Normal file
6
src/js/store/components/page-controls.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export default class PageControls {
|
||||||
|
constructor(store) {
|
||||||
|
console.log('page-controls init');
|
||||||
|
console.log(store);
|
||||||
|
}
|
||||||
|
}
|
8
src/js/store/configure.js
Normal file
8
src/js/store/configure.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import {
|
||||||
|
createStore,
|
||||||
|
} from 'redux'
|
||||||
|
import reducers from './reducers'
|
||||||
|
|
||||||
|
export default function configure() {
|
||||||
|
return createStore(reducers)
|
||||||
|
}
|
19
src/js/store/index.js
Normal file
19
src/js/store/index.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import configure from './configure'
|
||||||
|
const store = configure();
|
||||||
|
|
||||||
|
/*import {
|
||||||
|
PageControls
|
||||||
|
} from './components'*/
|
||||||
|
|
||||||
|
//const pageControls = new PageControls(store)
|
||||||
|
|
||||||
|
store.subscribe(() => console.log(store.getState()));
|
||||||
|
store.dispatch({
|
||||||
|
type: 'counter/incremented',
|
||||||
|
})
|
||||||
|
store.dispatch({
|
||||||
|
type: 'counter/incremented',
|
||||||
|
})
|
||||||
|
store.dispatch({
|
||||||
|
type: 'counter/decremented',
|
||||||
|
})
|
16
src/js/store/reducers/counter.js
Normal file
16
src/js/store/reducers/counter.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
export default function counter(state = {
|
||||||
|
value: 0,
|
||||||
|
}, action) {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'counter/incremented':
|
||||||
|
return {
|
||||||
|
value: state.value + 1,
|
||||||
|
}
|
||||||
|
case 'counter/decremented':
|
||||||
|
return {
|
||||||
|
value: state.value - 1,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
}
|
9
src/js/store/reducers/index.js
Normal file
9
src/js/store/reducers/index.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import {
|
||||||
|
combineReducers,
|
||||||
|
} from 'redux'
|
||||||
|
|
||||||
|
import counter from './counter';
|
||||||
|
|
||||||
|
export default combineReducers({
|
||||||
|
counter,
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user