I have a more theoretical question that addresses potential performance issues when working with observables in angular, because I kind of lack some basic understanding of how sap composable storefront (formerly known as spartacus), respectively angular “stores” HTTP Responses.
I know we want to reduce the amount of HTTP Requests fired in an angular application, but what about data that has been fetched and we refer to countless times within our app?
like for example I have a network call to the pages’s “BaseSite”-data that holds all kinds of information characterizing the app (language, currency, theme) and I wondered if it is an issue if you call a certain attribute via some baseSiteService like “langauge” repeated times.
Does it have any impact on the apps performance if I have a large array of components where every single one of them tries to reach out for “language” like this:
export SomeChildComponentUsed1000TimesOnTheSamePage{
hasFeature$ = this.baseSiteService.getBaseSiteData().pipe(
map(bs => bs.featureList.includes('FLAGX'))
);
}
To me it would make more sense to fetch this data once and then pass it as an input parameter to all components, but does it really have a noticable impact on the performance (assuming there is no complicated operation involving some more http requests)?
Years ago I even thought it would be a good Idea to fetch this data once in the app.component and write it to the localstorage via “StorageMap” and from then on directly get the data from the local storage whenever I need it, because I thought that would decrease traffic. Now I look at this code and wonder if that really was worth the refactoring.
Should I revert all those storageMap-workarounds and resort to the basic baseSiteService?
If so I really would like to understand how and where http-responses are actually stored in an angular.