I am using async pipe in the template. If you see my below code i am using async pipe in two different places. Because it is used in two places, it gets subscribed two time and there are two http calls made. How to avoid this one single call with async pipe? I was able to achieve without async by subscribe in ngOnInit() but would like to know how to achieve with single async pipe in my case?
<div class="flex-group space-between">
<h1>Heading</h1>
<div *ngIf="historyYears$ | async as historyYears; else loadingComponent">
<aa-alert alertClass="info" alertText="You have no training history" *ngIf="historyYears.length === 0"></aa-alert>
</div>
</div>
<div *ngIf="historyYears$ | async as historyYears; else loadingComponent">
<!--rest of code goes here -->
</div>
<ng-template #loadingComponent>
<app-loading></app-loading>
</ng-template>