Removed semicolons from LoadingBar middleware

• Removed:
- semicolons from LoadingBar middleware
This commit is contained in:
mgabdev 2020-08-05 23:21:35 -05:00
parent 22bd706236
commit c0f7e3adbf

View File

@ -1,25 +1,25 @@
import { showLoading, hideLoading } from 'react-redux-loading-bar'; import { showLoading, hideLoading } from 'react-redux-loading-bar'
const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED']; const defaultTypeSuffixes = ['PENDING', 'FULFILLED', 'REJECTED']
export default function loadingBarMiddleware(config = {}) { export default function loadingBarMiddleware(config = {}) {
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes; const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes
return ({ dispatch }) => next => (action) => { return ({ dispatch }) => next => (action) => {
if (action.type && !action.skipLoading) { if (action.type && !action.skipLoading) {
const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes; const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes
const isPending = new RegExp(`${PENDING}$`, 'g'); const isPending = new RegExp(`${PENDING}$`, 'g')
const isFulfilled = new RegExp(`${FULFILLED}$`, 'g'); const isFulfilled = new RegExp(`${FULFILLED}$`, 'g')
const isRejected = new RegExp(`${REJECTED}$`, 'g'); const isRejected = new RegExp(`${REJECTED}$`, 'g')
if (action.type.match(isPending)) { if (action.type.match(isPending)) {
dispatch(showLoading()); dispatch(showLoading())
} else if (action.type.match(isFulfilled) || action.type.match(isRejected)) { } else if (action.type.match(isFulfilled) || action.type.match(isRejected)) {
dispatch(hideLoading()); dispatch(hideLoading())
} }
} }
return next(action); return next(action)
}; }
}; }