From 54463a5954a9ac70c6b55b7032e2d1718dc6cac4 Mon Sep 17 00:00:00 2001 From: jymdman Date: Fri, 11 May 2018 20:25:55 +0200 Subject: [PATCH 1/2] (auth) Update to rxjs pipeable operators --- src/auth/auth.spec.ts | 8 ++------ src/auth/auth.ts | 13 +++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/auth/auth.spec.ts b/src/auth/auth.spec.ts index 26c58d22e..84f7f44f1 100644 --- a/src/auth/auth.spec.ts +++ b/src/auth/auth.spec.ts @@ -1,15 +1,11 @@ import { User } from '@firebase/auth-types'; import { ReflectiveInjector, Provider } from '@angular/core'; -import { Observable } from 'rxjs/Observable' -import { Subject } from 'rxjs/Subject' -import { Observer } from 'rxjs/Observer'; +import { Observable, Subject } from 'rxjs' import { TestBed, inject } from '@angular/core/testing'; -import { _do } from 'rxjs/operator/do'; -import { take } from 'rxjs/operator/take'; -import { skip } from 'rxjs/operator/skip'; import { FirebaseApp, FirebaseAppConfig, AngularFireModule, FirebaseAppName } from 'angularfire2'; import { AngularFireAuth, AngularFireAuthModule } from 'angularfire2/auth'; import { COMMON_CONFIG } from './test-config'; +import { take, skip } from 'rxjs/operators'; function authTake(auth: Observable, count: number): Observable { return take.call(auth, 1); diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 4ceb4feb5..ea5c8f364 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -1,13 +1,11 @@ import { FirebaseAuth, User } from '@firebase/auth-types'; import { FirebaseOptions } from '@firebase/app-types'; import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; +import { switchMap } from 'rxjs/operators'; import { FirebaseAppConfig, FirebaseAppName, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/observable/of'; -import 'rxjs/add/observable/fromPromise'; @Injectable() export class AngularFireAuth { @@ -55,10 +53,9 @@ export class AngularFireAuth { return { unsubscribe }; }) ) - ).switchMap((user:User|null) => { - return user ? Observable.fromPromise(user.getIdToken()) : Observable.of(null) - }); - + ).pipe(switchMap((user:User) => { + return user ? Observable.from(user.getIdToken()) : Observable.of(null) + })); } } From 6da377b54bc667838f70bc69917fc999abdb1e25 Mon Sep 17 00:00:00 2001 From: jymdman Date: Sat, 12 May 2018 00:48:49 +0200 Subject: [PATCH 2/2] Address comments --- src/auth/auth.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/auth/auth.ts b/src/auth/auth.ts index ea5c8f364..3ee817741 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -3,6 +3,8 @@ import { FirebaseOptions } from '@firebase/app-types'; import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core'; import { Observable } from 'rxjs'; import { switchMap } from 'rxjs/operators'; +import { of } from 'rxjs/observable/of'; +import { from } from 'rxjs/observable/from'; import { FirebaseAppConfig, FirebaseAppName, _firebaseAppFactory, FirebaseZoneScheduler } from 'angularfire2'; @@ -54,7 +56,7 @@ export class AngularFireAuth { }) ) ).pipe(switchMap((user:User) => { - return user ? Observable.from(user.getIdToken()) : Observable.of(null) + return user ? from(user.getIdToken()) : of(null) })); }