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


TypeScript PromiseObservable.create方法代碼示例

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


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

示例1: validateForgotPasswordModal

  validateForgotPasswordModal() {
    console.log('validateForgotPasswordModal');

    // make sure forgotEmail has a value
    let firebaseObs = PromiseObservable.create(this.firebase.sendPasswordResetEmail(this.forgotEmail));

    firebaseObs.subscribe(
      () => {
        console.log("sendPasswordResetEmail ");
        Materialize.toast("Email envoyé", 3000, 'rounded');
        this.cancelForgotPasswordModal();
        this.cd.detectChanges();
      },
      error => {
        /**
         * {code: "auth/invalid-email", message: "The email address is badly formatted."}code: "auth/invalid-email"message: "The email address is badly formatted."__proto__: Error
         *
         * O {code: "auth/user-not-found", message: "There is no user record corresponding to this identifier. The user may have been deleted."}code: "auth/user-not-found"message: "There is no user record corresponding to this identifier. The user may have been deleted."__proto__: Error
         */

        console.log("sendPasswordResetEmail fail reason", error);

        if (error != undefined) {
          if (error.code == "auth/invalid-email") {
            Materialize.toast("L'email n'est pas correctement formatté", 3000, 'rounded');
            return
          } else if (error.code == "auth/user-not-found") {
            Materialize.toast("L'email ne correspond à aucun de nos utilisateurs", 3000, 'rounded');
            return
          }
        }
        Materialize.toast("Une erreur est survenue", 3000, 'rounded');
      }
    ).unsubscribe();
  }
開發者ID:guillaumeLeRoy,項目名稱:eritis_fe,代碼行數:35,代碼來源:welcome-header.component.ts

示例2: fromPromise

 static fromPromise(promise: Promise<any>): Observable<any> {
   return PromiseObservable.create(promise);
 }
開發者ID:UI-TEAM,項目名稱:angular,代碼行數:3,代碼來源:async.ts


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