All files loading_bar_middleware.js

100% Statements 9/9
100% Branches 6/6
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 151x   5x 5x 7x   7x 1x 6x   2x        
import { showLoading, hideLoading } from './loading_bar_ducks'
 
export default function loadingBarMiddleware({ dispatch }) {
  return next => action => {
    next(action)
 
    if (action.type.includes('_PENDING')) {
      dispatch(showLoading())
    } else if (action.type.includes('_FULFILLED') ||
               action.type.includes('_REJECTED')) {
      dispatch(hideLoading())
    }
  }
}