actions.js 368 B

1234567891011121314
  1. export const increment = ({ dispatch }) => dispatch('INCREMENT')
  2. export const decrement = ({ dispatch }) => dispatch('DECREMENT')
  3. export const incrementIfOdd = ({ dispatch, state }) => {
  4. if ((state.count + 1) % 2 === 0) {
  5. dispatch('INCREMENT')
  6. }
  7. }
  8. export const incrementAsync = ({ dispatch }) => {
  9. setTimeout(() => {
  10. dispatch('INCREMENT')
  11. }, 1000)
  12. }