本文整理匯總了TypeScript中rxjs/observable/PromiseObservable.PromiseObservable類的典型用法代碼示例。如果您正苦於以下問題:TypeScript PromiseObservable類的具體用法?TypeScript PromiseObservable怎麽用?TypeScript PromiseObservable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PromiseObservable類的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();
}
示例2: fromPromise
static fromPromise(promise: Promise<any>): Observable<any> {
return PromiseObservable.create(promise);
}