0
Consider the following method:
private handleError<T> (operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
this.log(`${operation} failed: ${error.message}`);
return of(result as T);
};
}
whereas the implementation of a generic type implies a return of the same generic type T
, why the need to use the result as T
, whereas result
will always be the type T
?
return of(result as T);
What is this
of
?– Maniero
@Maniero is a method of
Observable
, that belongs to the Rxjs library used in Angular.– Filipe Moraes