@@ -2,40 +2,40 @@ import { Observable } from 'rxjs/Observable';
2
2
import { Operator } from 'rxjs/Operator' ;
3
3
import { Subscriber } from 'rxjs/Subscriber' ;
4
4
import { Subscription } from 'rxjs/Subscription' ;
5
+ import * as firebase from 'firebase' ;
5
6
import * as utils from '../utils' ;
6
- import {
7
- AFUnwrappedDataSnapshot ,
8
- FirebaseOperationCases
7
+ import {
8
+ AFUnwrappedDataSnapshot ,
9
+ FirebaseOperationCases
9
10
} from '../interfaces' ;
10
11
11
12
export type FirebaseOperation = string | firebase . database . Reference | firebase . database . DataSnapshot | AFUnwrappedDataSnapshot ;
12
13
13
14
export class FirebaseListObservable < T > extends Observable < T > {
14
- constructor ( public _ref : firebase . database . Reference | firebase . database . Query , subscribe ?: < R > ( subscriber : Subscriber < R > ) => Subscription | Function | void ) {
15
+ constructor ( public $ref : firebase . database . Reference | firebase . database . Query , subscribe ?: < R > ( subscriber : Subscriber < R > ) => Subscription | Function | void ) {
15
16
super ( subscribe ) ;
16
17
}
17
18
lift < T , R > ( operator : Operator < T , R > ) : Observable < R > {
18
- const observable = new FirebaseListObservable < R > ( this . _ref ) ;
19
+ const observable = new FirebaseListObservable < R > ( this . $ref ) ;
19
20
observable . source = this ;
20
21
observable . operator = operator ;
21
- observable . _ref = this . _ref ;
22
+ observable . $ref = this . $ref ;
22
23
return observable ;
23
24
}
24
25
25
26
push ( val :any ) :firebase . database . ThenableReference {
26
- if ( ! this . _ref ) {
27
+ if ( ! this . $ref ) {
27
28
throw new Error ( 'No ref specified for this Observable!' ) ;
28
29
}
29
- this . _ref . ref
30
- return this . _ref . ref . push ( val ) ;
30
+ return this . $ref . ref . push ( val ) ;
31
31
}
32
32
33
33
update ( item : FirebaseOperation , value : Object ) : firebase . Promise < void > {
34
34
return this . _checkOperationCases ( item , {
35
- stringCase : ( ) => this . _ref . ref . child ( < string > item ) . update ( value ) ,
35
+ stringCase : ( ) => this . $ref . ref . child ( < string > item ) . update ( value ) ,
36
36
firebaseCase : ( ) => ( < firebase . database . Reference > item ) . update ( value ) ,
37
37
snapshotCase : ( ) => ( < firebase . database . DataSnapshot > item ) . ref . update ( value ) ,
38
- unwrappedSnapshotCase : ( ) => this . _ref . ref . child ( ( < AFUnwrappedDataSnapshot > item ) . $key ) . update ( value )
38
+ unwrappedSnapshotCase : ( ) => this . $ref . ref . child ( ( < AFUnwrappedDataSnapshot > item ) . $key ) . update ( value )
39
39
} ) ;
40
40
}
41
41
@@ -45,13 +45,13 @@ export class FirebaseListObservable<T> extends Observable<T> {
45
45
46
46
// if no item parameter is provided, remove the whole list
47
47
if ( ! item ) {
48
- return this . _ref . ref . remove ( ) ;
48
+ return this . $ref . ref . remove ( ) ;
49
49
}
50
50
return this . _checkOperationCases ( item , {
51
- stringCase : ( ) => this . _ref . ref . child ( < string > item ) . remove ( ) ,
51
+ stringCase : ( ) => this . $ref . ref . child ( < string > item ) . remove ( ) ,
52
52
firebaseCase : ( ) => ( < firebase . database . Reference > item ) . remove ( ) ,
53
53
snapshotCase : ( ) => ( < firebase . database . DataSnapshot > item ) . ref . remove ( ) ,
54
- unwrappedSnapshotCase : ( ) => this . _ref . ref . child ( ( < AFUnwrappedDataSnapshot > item ) . $key ) . remove ( )
54
+ unwrappedSnapshotCase : ( ) => this . $ref . ref . child ( ( < AFUnwrappedDataSnapshot > item ) . $key ) . remove ( )
55
55
} ) ;
56
56
}
57
57
0 commit comments