1
- import { InjectionToken , NgZone } from '@angular/core' ;
2
- import { Observable } from 'rxjs/Observable' ;
3
- import { Subscription } from 'rxjs/Subscription' ;
4
- import { queue } from 'rxjs/scheduler/queue' ;
5
- import { isPlatformServer } from '@angular/common' ;
6
- import { observeOn } from 'rxjs/operator/observeOn' ;
1
+ import 'rxjs/add/operator/first' ;
7
2
3
+ import { isPlatformServer } from '@angular/common' ;
4
+ import { InjectionToken , NgZone } from '@angular/core' ;
8
5
import firebase from '@firebase/app' ;
9
- import { FirebaseApp , FirebaseOptions } from '@firebase/app-types' ;
10
-
11
- import 'zone.js' ;
12
- import 'rxjs/add/operator/first' ;
6
+ import { FirebaseApp , FirebaseOptions } from '@firebase/app-types' ;
7
+ import { Observable } from 'rxjs/Observable' ;
8
+ import { observeOn } from 'rxjs/operator/observeOn' ;
9
+ import { queue } from 'rxjs/scheduler/queue' ;
10
+ import { Subscription } from 'rxjs/Subscription' ;
11
+ import { } from 'zone.js' ;
13
12
14
- export const FirebaseAppName = new InjectionToken < string > ( 'angularfire2.appName' ) ;
15
- export const FirebaseAppConfig = new InjectionToken < FirebaseOptions > ( 'angularfire2.config' ) ;
13
+ export const FirebaseAppName =
14
+ new InjectionToken < string > ( 'angularfire2.appName' ) ;
15
+ export const FirebaseAppConfig =
16
+ new InjectionToken < FirebaseOptions > ( 'angularfire2.config' ) ;
16
17
17
18
// Put in database.ts when we drop database-depreciated
18
- export const RealtimeDatabaseURL = new InjectionToken < string > ( 'angularfire2.realtimeDatabaseURL' ) ;
19
+ export const RealtimeDatabaseURL =
20
+ new InjectionToken < string > ( 'angularfire2.realtimeDatabaseURL' ) ;
19
21
20
22
export class FirebaseZoneScheduler {
21
23
constructor ( public zone : NgZone , private platformId : Object ) { }
22
24
schedule ( ...args : any [ ] ) : Subscription {
23
- return < Subscription > this . zone . runGuarded ( function ( ) { return queue . schedule . apply ( queue , args ) } ) ;
25
+ return < Subscription > this . zone . runGuarded ( function ( ) {
26
+ return queue . schedule . apply ( queue , args )
27
+ } ) ;
24
28
}
25
29
// TODO this is a hack, clean it up
26
30
keepUnstableUntilFirst < T > ( obs$ : Observable < T > ) {
27
31
if ( isPlatformServer ( this . platformId ) ) {
28
32
return new Observable < T > ( subscriber => {
29
33
const noop = ( ) => { } ;
30
- const task = Zone . current . scheduleMacroTask ( 'firebaseZoneBlock' , noop , { } , noop , noop ) ;
31
- obs$ . first ( ) . subscribe ( ( ) => this . zone . runOutsideAngular ( ( ) => task . invoke ( ) ) ) ;
34
+ const task = Zone . current . scheduleMacroTask (
35
+ 'firebaseZoneBlock' , noop , { } , noop , noop ) ;
36
+ obs$ . first ( ) . subscribe (
37
+ ( ) => this . zone . runOutsideAngular ( ( ) => task . invoke ( ) ) ) ;
32
38
return obs$ . subscribe ( subscriber ) ;
33
39
} ) ;
34
40
} else {
@@ -39,11 +45,11 @@ export class FirebaseZoneScheduler {
39
45
return new Observable < T > ( subscriber => {
40
46
return this . zone . runOutsideAngular ( ( ) => {
41
47
return obs$ . subscribe (
42
- value => this . zone . run ( ( ) => subscriber . next ( value ) ) ,
43
- error => this . zone . run ( ( ) => subscriber . error ( error ) ) ,
44
- ( ) => this . zone . run ( ( ) => subscriber . complete ( ) ) ,
48
+ value => this . zone . run ( ( ) => subscriber . next ( value ) ) ,
49
+ error => this . zone . run ( ( ) => subscriber . error ( error ) ) ,
50
+ ( ) => this . zone . run ( ( ) => subscriber . complete ( ) ) ,
45
51
) ;
46
52
} ) ;
47
53
} ) ;
48
54
}
49
- }
55
+ }
0 commit comments