@@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core';
2
2
import { Observable } from 'rxjs/Observable' ;
3
3
import { Observer } from 'rxjs/Observer' ;
4
4
import { FirebaseApp } from '../tokens' ;
5
- import { isPresent } from '../utils' ;
5
+ import { isPresent , ZoneScheduler } from '../utils' ;
6
6
import { auth } from 'firebase' ;
7
7
import {
8
8
authDataToAuthState ,
@@ -22,6 +22,7 @@ const {
22
22
23
23
import 'rxjs/add/operator/map' ;
24
24
import 'rxjs/add/observable/fromPromise' ;
25
+ import 'rxjs/add/operator/observeOn' ;
25
26
26
27
@Injectable ( )
27
28
export class FirebaseSdkAuthBackend extends AuthBackend {
@@ -42,14 +43,20 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
42
43
}
43
44
44
45
onAuth ( ) : Observable < FirebaseAuthState > {
45
- // TODO: assumes this will accept an RxJS observer
46
46
return Observable . create ( ( observer : Observer < FirebaseAuthState > ) => {
47
47
return this . _fbAuth . onAuthStateChanged ( observer ) ;
48
48
} )
49
49
. map ( ( user : firebase . User ) => {
50
50
if ( ! user ) return null ;
51
51
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 ) ) ;
53
60
}
54
61
55
62
unauth ( ) : void {
0 commit comments