From 5c45280bc75f3211c15ba6a21076cb423b7592cb Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Fri, 28 Jan 2022 19:01:00 +0100 Subject: [PATCH] - Updated example in documentation - Updated imports of Angular request --- docs/angular-support.md | 11 ++++++++--- src/templates/core/angular/request.hbs | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/angular-support.md b/docs/angular-support.md index aa027c9e..45905fd3 100644 --- a/docs/angular-support.md +++ b/docs/angular-support.md @@ -49,6 +49,8 @@ Inside the component you can inject the service and just use it as you would wit ```typescript import { Component } from '@angular/core'; +import { throwError} from 'rxjs'; +import { catchError, map, retry } from 'rxjs/operators'; import type { OrganizationService } from './generated/services/OrganizationService'; @@ -59,7 +61,7 @@ import type { OrganizationService } from './generated/services/OrganizationServi export class AppComponent { constructor(private readonly organizationService: OrganizationService) { - // Make a call + // Supports making a simple call this.organizationService .createOrganization({ name: 'OrgName', @@ -69,12 +71,15 @@ export class AppComponent { console.log(organization); }); - // Or even map result and retry on error + // Or creating flows with rety(), catchError() and map() this.organizationService .getOrganizations() .pipe( + retry(3), + catchError(error => + throwError(error) + ), map(organizations => organizations[0]), - retryWhen(error => error) ) .subscribe(organization => { console.log(organization); diff --git a/src/templates/core/angular/request.hbs b/src/templates/core/angular/request.hbs index 1a31324b..57c98516 100644 --- a/src/templates/core/angular/request.hbs +++ b/src/templates/core/angular/request.hbs @@ -2,7 +2,8 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; import type { HttpResponse, HttpErrorResponse } from '@angular/common/http'; -import { catchError, forkJoin, map, switchMap, of, throwError } from 'rxjs'; +import { forkJoin, of, throwError } from 'rxjs'; +import { catchError, map, switchMap } from 'rxjs/operators'; import type { Observable } from 'rxjs'; import { ApiError } from './ApiError';