Why is typecasting the Observable a standard? What is happening under the hood? It is solely for compile time assertion?
Here is an example of:
getAnything = (): Observable<Data> => {
return this.httpclient.get('https://my_api.com')
.map(this.handleSuccess)
.catch(this.handleError);
}
And why not this :
getAnything = (): {
return this.http.get('https://my_api.com')
.map(this.handleSuccess)
.catch(this.handleError);
}
HTTP Client returns Observable, but why do we want to typecast Observable, what are the pros for this?
I tried searching Angular documentation however was not able to find the specific reason for this