Removed semicolons from LoadingBar middleware
• Removed: - semicolons from LoadingBar middleware
This commit is contained in:
parent
22bd706236
commit
c0f7e3adbf
@ -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 = {}) {
|
||||
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes;
|
||||
const promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypeSuffixes
|
||||
|
||||
return ({ dispatch }) => next => (action) => {
|
||||
if (action.type && !action.skipLoading) {
|
||||
const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes;
|
||||
const [PENDING, FULFILLED, REJECTED] = promiseTypeSuffixes
|
||||
|
||||
const isPending = new RegExp(`${PENDING}$`, 'g');
|
||||
const isFulfilled = new RegExp(`${FULFILLED}$`, 'g');
|
||||
const isRejected = new RegExp(`${REJECTED}$`, 'g');
|
||||
const isPending = new RegExp(`${PENDING}$`, 'g')
|
||||
const isFulfilled = new RegExp(`${FULFILLED}$`, 'g')
|
||||
const isRejected = new RegExp(`${REJECTED}$`, 'g')
|
||||
|
||||
if (action.type.match(isPending)) {
|
||||
dispatch(showLoading());
|
||||
dispatch(showLoading())
|
||||
} else if (action.type.match(isFulfilled) || action.type.match(isRejected)) {
|
||||
dispatch(hideLoading());
|
||||
dispatch(hideLoading())
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
};
|
||||
};
|
||||
return next(action)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user