@@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core';
22import { Observable } from 'rxjs/Observable' ;
33import { Observer } from 'rxjs/Observer' ;
44import { FirebaseApp } from '../tokens' ;
5- import { isPresent } from '../utils' ;
5+ import { isPresent , ZoneScheduler } from '../utils' ;
66import { auth } from 'firebase' ;
77import {
88 authDataToAuthState ,
@@ -22,6 +22,7 @@ const {
2222
2323import 'rxjs/add/operator/map' ;
2424import 'rxjs/add/observable/fromPromise' ;
25+ import 'rxjs/add/operator/observeOn' ;
2526
2627@Injectable ( )
2728export class FirebaseSdkAuthBackend extends AuthBackend {
@@ -42,14 +43,20 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
4243 }
4344
4445 onAuth ( ) : Observable < FirebaseAuthState > {
45- // TODO: assumes this will accept an RxJS observer
4646 return Observable . create ( ( observer : Observer < FirebaseAuthState > ) => {
4747 return this . _fbAuth . onAuthStateChanged ( observer ) ;
4848 } )
4949 . map ( ( user : firebase . User ) => {
5050 if ( ! user ) return null ;
5151 return authDataToAuthState ( user ) ;
52- } ) ;
52+ } )
53+ /**
54+ * TODO: since the auth service automatically subscribes to this before
55+ * any user, it will run in the Angular zone, instead of the subscription
56+ * zone. The auth service should be refactored to capture the subscription
57+ * zone and not use a ReplaySubject.
58+ **/
59+ . observeOn ( new ZoneScheduler ( Zone . current ) ) ;
5360 }
5461
5562 unauth ( ) : void {
0 commit comments