I have a requirement where I have to make a api call every minute irrespective of current page, i.e throughout the app (Angular 7 app). what is best place to call this api (App component or anywhere better place), so that I din't make any design mistake. your suggestions will be appreciated
I would do it in a Service which would be created and used by the AppComponent.
It's recommended that HttpClient calls are wrapped within services instead of being used in Components directly. This allows for greater flexibility for your application structure as you can reuse your your calls throughout the app, as well the ability to implement more advanced features such as caching.
And the timer would be in the AppComponent, not in the Service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With