diff options
Diffstat (limited to 'src/reducers/loading.reducer.js')
-rw-r--r-- | src/reducers/loading.reducer.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/reducers/loading.reducer.js b/src/reducers/loading.reducer.js new file mode 100644 index 0000000..5ff7651 --- /dev/null +++ b/src/reducers/loading.reducer.js @@ -0,0 +1,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') + }; + +}
\ No newline at end of file |