本文整理汇总了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();
}
示例2: fromPromise
static fromPromise(promise: Promise<any>): Observable<any> {
return PromiseObservable.create(promise);
}