Skip to content

Commit

Permalink
fix(auth): Update to rxjs pipeable operators (#1621)
Browse files Browse the repository at this point in the history
  • Loading branch information
jymdman authored and jamesdaniels committed May 11, 2018
1 parent 5c3681d commit 0c3b215
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
8 changes: 2 additions & 6 deletions 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<any>, count: number): Observable<any> {
return take.call(auth, 1);
Expand Down
15 changes: 7 additions & 8 deletions src/auth/auth.ts
@@ -1,13 +1,13 @@
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 { of } from 'rxjs/observable/of';
import { from } from 'rxjs/observable/from';

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 {
Expand Down Expand Up @@ -55,10 +55,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 ? from(user.getIdToken()) : of(null)
}));
}

}

0 comments on commit 0c3b215

Please sign in to comment.