If more than one component is trying to make an HTTP call to same URL, then how can you restrict making 2 network calls?

Technology CommunityCategory: IonicIf more than one component is trying to make an HTTP call to same URL, then how can you restrict making 2 network calls?
VietMX Staff asked 3 years ago

One of the important areas which would majorly affect the performance of the app is network calls. It should be tuned to the highest accuracy to make the app perform better.

  1. If two different components trying to make an HTTP call to the same URL means, it is better to make a single call and send data to both the components, rather making two different HTTP calls. The provided request is done in a gap of few seconds.
  2. Best way to achieve this is using a root component. All the components making an HTTP call should go with a common root component. Which keeps track of the URLs that have been requested a few seconds back, if same is requested again, then it can add a  minimum delay and once response comes, it can send it to both the components.