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


TypeScript Observer.error方法代碼示例

本文整理匯總了TypeScript中rxjs.Observer.error方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observer.error方法的具體用法?TypeScript Observer.error怎麽用?TypeScript Observer.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs.Observer的用法示例。


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

示例1: Error

 return Observable.create((observer: Observer<any>) => {
   if (!patch || !patch.name) {
     return observer.error(new Error('User name is required'))
   }
   Observable.fromPromise(userFetch.update(patch))
     .concatMap(x => UserModel.update(x))
     .forEach(result => observer.next(result))
 })
開發者ID:rucky2013,項目名稱:teambition-sdk,代碼行數:8,代碼來源:UserAPI.ts

示例2:

 const onComplete = () => {
   if (savedError !== null) {
     observer.error(savedError);
   } else {
     observer.next(savedResult);
     observer.complete();
   }
 };
開發者ID:IdeaBlade,項目名稱:angular,代碼行數:8,代碼來源:http.ts

示例3: return

 return ({ err, response, isDisposed }: WritePacket) => {
   if (err) {
     return observer.error(err);
   } else if (isDisposed) {
     return observer.complete();
   }
   observer.next(response);
 };
開發者ID:a1r0,項目名稱:nest,代碼行數:8,代碼來源:client-proxy.ts

示例4: handleInvalidWorkstation

    handleInvalidWorkstation(path: string): void {

        if (path.startsWith(WS_MANAGE_PATH)) {
            // user is navigating to the WS admin page.
            this.observer.complete();
        } else {
            this.router.navigate([WS_MANAGE_PATH]);
            this.observer.error(`Auth session linked to no
                workstation or a workstation unknown to this browser`);
        }
    }
開發者ID:StephenGWills,項目名稱:Evergreen,代碼行數:11,代碼來源:resolver.service.ts

示例5: catch

 .then((data) => {
     try {
         const json = JSON.parse(data);
         observer.next(successResponse(url, json, 200));
         observer.complete();
     } catch (error) {
         // Even though the response status was 2xx, this is still an error.
         // The parse error contains the text of the body that failed to parse.
         const errorResult = { error, text: data };
         observer.error(errorResponse(url, errorResult, 200));
     }
 }, (err: Object) => {
開發者ID:NathanWalker,項目名稱:nativescript-angular,代碼行數:12,代碼來源:http-utils.ts

示例6:

 return new Observable<any>((responseObserver: Observer<any>) => {
   if (navigator.geolocation) {
     navigator.geolocation.getCurrentPosition(
       (position) => {
         responseObserver.next(position);
         responseObserver.complete();
       },
       (evt) => responseObserver.error(evt),
       geoLocationOptions
     );
   } else {
     responseObserver.error('Browser Geolocation service failed.');
   }
 });
開發者ID:ng2-ui,項目名稱:ng2-map,代碼行數:14,代碼來源:navigator-geolocation.ts

示例7:

 newRef.set(value, (err: Error) => {
   if (err) {
     observer.error({
       type: `CREATE_FAILED_IN_${PREFIX}`,
       payload: {
         originalPayload: value,
         error: err,
       }
     });
   } else {
     observer.next({
       type: `CREATED_IN_${PREFIX}`,
       payload: Object.assign({}, value, { firebaseKey: newRef.key() })
     });
   }
 });
開發者ID:vire,項目名稱:hlad-ui,代碼行數:16,代碼來源:firebase.ts

示例8: fn

 return Observable.create((observer: Observer<any>) => {
   try {
     if (!called) {
       called = true;
       fn()
         .then((_record: any) => {
           record = _record;
           observer.next(record);
           observer.complete();
         })
         .catch((err: any) => observer.error(err));
     } else if (record) {
       observer.next(record);
       observer.complete();
     }
   } catch (err) {
     observer.error(err);
   }
 });
開發者ID:formio,項目名稱:ng2-formio,代碼行數:19,代碼來源:formio.service.ts

示例9: Observable

    return new Observable((observer: Observer<T>) => {
        if (nsFileSystem.fileExists(url)) {
            const localFile = nsFileSystem.fileFromPath(url);
            localFile.readText()
                .then((data) => {
                    try {
                        const json = JSON.parse(data);
                        observer.next(successResponse(url, json, 200));
                        observer.complete();
                    } catch (error) {
                        // Even though the response status was 2xx, this is still an error.
                        // The parse error contains the text of the body that failed to parse.
                        const errorResult = { error, text: data };
                        observer.error(errorResponse(url, errorResult, 200));
                    }
                }, (err: Object) => {
                    observer.error(errorResponse(url, err, 400));

                });
        } else {
            observer.error(errorResponse(url, "Not Found", 404));
        }
    });
開發者ID:NathanWalker,項目名稱:nativescript-angular,代碼行數:23,代碼來源:http-utils.ts


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