'Mapping result with rxjs in Angular
I need some help with rxjs in Angular.
I have an API that returns a paginated list of my data from the backend. There data is inside the content attribute of the result. Each entry of the content DOES NOT have an expanded attribute. When I define the interface for the model on the frontend I added that field but now I need to initialize it somehow. This code is working with the for loop but I know it can be done somehow with pipe and map in rxjs.
Cold you suggest how can I do it?
this.service.getData(page, size, id)
.pipe(
catchError(() => of([])),
finalize(() => this.loadingSubject.next(false))
)
.subscribe((result: DataPage) => {
this.dataSubject.next(result.content);
for(let entry of this.dataSubject.value) {
entry.expanded = false;
this.totalElementsSubject.next(result.totalElements);
this.loadingSubject.next(false);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
