mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-16 06:36:48 +03:00
34 lines
559 B
JavaScript
34 lines
559 B
JavaScript
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants/ActionTypes';
|
|
|
|
export function increment() {
|
|
return {
|
|
type: INCREMENT_COUNTER
|
|
};
|
|
}
|
|
|
|
export function decrement() {
|
|
return {
|
|
type: DECREMENT_COUNTER
|
|
};
|
|
}
|
|
|
|
export function incrementIfOdd() {
|
|
return (dispatch, getState) => {
|
|
const { counter } = getState();
|
|
|
|
if (counter % 2 === 0) {
|
|
return;
|
|
}
|
|
|
|
dispatch(increment());
|
|
};
|
|
}
|
|
|
|
export function incrementAsync() {
|
|
return dispatch => {
|
|
setTimeout(() => {
|
|
dispatch(increment());
|
|
}, 1000);
|
|
};
|
|
}
|