0

I want to have just one loader (backdrop and spinner) inside app component and show it when i need (depends on redux state's property called showLoader) in every where of my react application. So I have a global reducer called appReducer which is contains showLoader property. the question is how can i change showLoader inside another reducer, orderReducer when i need?

for example when dispatch FETCH_ORDERS_REQUEST action, showLoader should be true and after that when FETCH_ORDERS_SUCCESS action dispatched, showLoader should be false. How can i do that? Thank you

Apostolos
  • 10,033
  • 5
  • 24
  • 39

1 Answers1

0

Just use multiple action types in global reducer:

switch (type) {
  case FETCH_ORDERS_REQUEST:
  case OTHER_REQUEST:
    return {
      loading: true
    }
  case FETCH_ORDERS_REQUEST_SUCCESS:
  case OTHER_REQUEST_SUCCESS:
    return {
      loading: false
    }

}
demkovych
  • 7,827
  • 3
  • 19
  • 25