Excuse me for the rookie question, I'm new in react.
I have multiple components in some of which I make Api calls in interval to keep the list up to date.
In Angular, I could create a service broadcasting an event in intervals using requestAnimationFrame
and make Api calls in those events. This is a good idea because:
- We're not creating many intervals in many components, staying DRY.
- We're reducing the risk of non-destroyed intervals.
- We're saving Api calls when application is not in active tab.
- We can manipulate the rate of Api call in a single service.
and some other advantages.
In many cases like this I read it's not a good approach to do the same in react/redux and we better try keeping action dispatches to a minimum. but if I creat an interval in every component it's not DRY anymore.
My question is which one of these ways I should choose or is there another approach?