當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript catchError.catchError函數代碼示例

本文整理匯總了TypeScript中rxjs/operators/catchError.catchError函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript catchError函數的具體用法?TypeScript catchError怎麽用?TypeScript catchError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了catchError函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: readRequest

 protected readRequest(state: State): Observable<HttpResponse<Object>> {
     return this.getDataSource().pipe(
         switchMap(dataSource => dataSource.read(this.getFilterOptions(state))),
         map(data => this.parseDSResponse(data)),
         catchError((error, retry) => _throw(this.getErrorResponse(error)))
     );
 }
開發者ID:telerik,項目名稱:kendo-angular2,代碼行數:7,代碼來源:progress.service.ts

示例2: switchMap

 switchMap((action: ActionStockMarketRetrieve) =>
   this.service
     .retrieveStock(action.payload.symbol)
     .pipe(
       map(stock => new ActionStockMarketRetrieveSuccess({ stock })),
       catchError(error =>
         of(new ActionStockMarketRetrieveError({ error }))
       )
     )
開發者ID:spairo,項目名稱:angular-ngrx-material-starter,代碼行數:9,代碼來源:stock-market.effects.ts

示例3:

 resolveFn: (catalog: CatalogService, state: StateService, loading: TdLoadingService) => {
     loading.register(ConnectorComponent.LOADER);
     return catalog.getConnector(state.transition.params().connectorId)
         .pipe(finalize(() => loading.resolve(ConnectorComponent.LOADER)))
         .pipe(catchError(() => {
             return state.go("catalog.connectors")
         }))
         .toPromise();
 }
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:9,代碼來源:catalog.states.ts

示例4: handleOperation

 protected handleOperation(operation: (dataSource: DataSource) => void): Observable<any> {
     return this.getDataSource().pipe(
         switchMap(dataSource => {
             operation(dataSource);
             return dataSource.saveChanges();
         }),
         catchError((error, retry) => _throw(this.getErrorResponse(error)))
     );
 }
開發者ID:telerik,項目名稱:kendo-angular2,代碼行數:9,代碼來源:progress.service.ts

示例5: switchMap

 switchMap(action =>
   this.service.retrieveStock(action.payload).pipe(
     map(stock => ({
       type: STOCK_MARKET_RETRIEVE_SUCCESS,
       payload: stock
     })),
     catchError(err =>
       of({ type: STOCK_MARKET_RETRIEVE_ERROR, payload: err })
     )
   )
開發者ID:a727891,項目名稱:bb,代碼行數:10,代碼來源:stock-market.effects.ts

示例6: intercept

 intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
   const accessToken = this.tokenStoreService.getRawAuthToken(AuthTokenType.AccessToken);
   if (accessToken) {
     request = request.clone({
       headers: request.headers.set("Authorization", `Bearer ${accessToken}`)
     });
     return next.handle(request).pipe(
       catchError((error: any, caught: Observable<HttpEvent<any>>) => {
         console.error({ error, caught });
         if (error.status === 401 || error.status === 403) {
           this.router.navigate(["/accessDenied"]);
         }
         return ErrorObservable.create(error);
       })
     );
   } else {
     // login page
     return next.handle(request);
   }
 }
開發者ID:nogueirawagner,項目名稱:jwt-authentication-aspnet-core,代碼行數:20,代碼來源:auth.interceptor.ts


注:本文中的rxjs/operators/catchError.catchError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。