I have an Angular 5 application in which I have to call some heavy REST service (usually takes some seconds). I need its result in different part of application, so I would
async getResult(): Promise {
if (typeof this.result === 'undefined')
{
// save result
this.result = await this.service.call()
.toPromise()
.then(resp =>resp as MyCustomObject);//Do you own cast here
}
return this.result;
}