All files loading_bar_ducks.js

100% Statements 13/13
92.31% Branches 12/13
100% Functions 3/3
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x     3x           5x         14x 7x   7x   3x 3x   3x 3x   1x     6x    
export const SHOW = 'loading-bar/SHOW'
export const HIDE = 'loading-bar/HIDE'
 
export function showLoading() {
  return {
    type: SHOW,
  }
}
 
export function hideLoading() {
  return {
    type: HIDE,
  }
}
 
export function loadingBarReducer(state = 0, action = {}) {
  let newState
 
  switch (action.type) {
    case SHOW:
      newState = state + 1
      break
    case HIDE:
      newState = state > 0 ? state - 1 : 0
      break
    default:
      return state
  }
 
  return newState
}