Answer the question
In order to leave comments, you need to log in
How to properly handle an exception for an async pipe?
I have a method like this - which returns an observable this.applicationObs
with data:
this.applicationObs = this.route.paramMap.pipe(
filter((params) => params.has('id')),
switchMap((params) => this.applicationService.getApplicationDetails(params.get('id'))),
tap((response) => {
const fabricaSidebar = fabricApplicationSidebarMenu(response.application);
this.sidebarSections = fabricaSidebar.getSidebarMenuItems();
}),
);
<ng-template #loading>
<div class="loader">
<mat-spinner [diameter]="50"></mat-spinner>
</div>
</ng-template>
<code><ng-template #loading>
<div class="loader">
<mat-spinner [diameter]="50"></mat-spinner>
</div>
</ng-template></code>
Answer the question
In order to leave comments, you need to log in
You can try to make such a wrapper for requests
function requestWrapper(request) {
return concat(
of({
loading: true,
completed: false,
value: null,
error: null,
}),
request.pipe(
map(value => ({
loading: false,
completed: true,
value,
error: null,
})),
catchError(error => of({
loading: false,
completed: true,
value: null,
error,
}))
)
)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question