1
0

actions.js 352 B

12345678910111213141516171819
  1. import { INCREMENT, DECREMENT } from './mutation-types'
  2. export default {
  3. increment: INCREMENT,
  4. decrement: DECREMENT,
  5. incrementIfOdd: ({ dispatch, state }) => {
  6. if ((state.count + 1) % 2 === 0) {
  7. dispatch(INCREMENT)
  8. }
  9. },
  10. incrementAsync: ({ dispatch }) => {
  11. setTimeout(() => {
  12. dispatch(INCREMENT)
  13. }, 1000)
  14. }
  15. }