// JUST A REDUX EXAMPLE!!
// I'LL CHANGE THIS VERY SOON!

export const SET_COUNTER = 'SET_COUNTER'
export const INCREMENT_COUNTER = 'INCREMENT_COUNTER'
export const DECREMENT_COUNTER = 'DECREMENT_COUNTER'

export function set (value) {
  return {
    type: SET_COUNTER,
    payload: value
  }
}

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 incremetAsync (delay = 1000) {
  return dispatch => {
    setTimeout(function () {
      dispatch(increment())
    }, delay)
  }
}

Update actions