aboutsummaryrefslogtreecommitdiff
path: root/src/reducers/loading.reducer.js
blob: 5ff76514bdcb0b5d6bd8ca80f6d7cf953b59786a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
export default function LoadingReducer(state = {}, action) {
    console.log("Reducer",action)
    const { type } = action;
    const matches = /(.*)_(REQUEST|SUCCESS|FAILED|ERROR|SUBMIT|CANCEL)/.exec(type);
    if (!matches) return state;
    const [, requestName, requestState] = matches;
    return {
        ...state,
        [requestName]: (requestState === 'REQUEST' || requestState === 'SUBMIT')
    };

}