本文整理匯總了TypeScript中angularfire2.FirebaseApp.auth方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript FirebaseApp.auth方法的具體用法?TypeScript FirebaseApp.auth怎麽用?TypeScript FirebaseApp.auth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angularfire2.FirebaseApp
的用法示例。
在下文中一共展示了FirebaseApp.auth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
const idToken = Observable.create((observer: Observer<firebase.User>) => {
app.auth().onIdTokenChanged(
(user: firebase.User) => observer.next(user!),
(error: firebase.auth.Error) => observer.error(error),
() => { observer.complete(); return undefined; }
)
});
示例2: constructor
constructor(public app: FirebaseApp) {
this.auth = app.auth();
const authState$ = new Observable(subscriber => {
const unsubscribe = this.auth.onAuthStateChanged(subscriber);
return { unsubscribe };
});
this.authState = observeOn.call(authState$, new ZoneScheduler(Zone.current));
const idToken$ = new Observable<firebase.User|null>(subscriber => {
const unsubscribe = this.auth.onIdTokenChanged(subscriber);
return { unsubscribe };
}).switchMap(user => {
return user ? Observable.fromPromise(user.getIdToken()) : Observable.of(null)
});
this.idToken = observeOn.call(idToken$, new ZoneScheduler(Zone.current));
}
示例3: constructor
constructor(public app: FirebaseApp) {
this.authState = FirebaseAuthStateObservable(app);
this.idToken = FirebaseIdTokenObservable(app);
this.auth = app.auth();
}