@@ -11,8 +11,9 @@ const FirestackModuleEvt = new NativeEventEmitter(FirestackModule);
11
11
12
12
const logs = { } ;
13
13
14
+ type FirestackOptions = { } ;
14
15
export class Base extends EventEmitter {
15
- constructor ( firestack , options = { } ) {
16
+ constructor ( firestack : Object , options : FirestackOptions = { } ) {
16
17
super ( ) ;
17
18
this . firestack = firestack ;
18
19
this . eventHandlers = { } ;
@@ -22,7 +23,7 @@ export class Base extends EventEmitter {
22
23
}
23
24
24
25
// Logger
25
- get log ( ) {
26
+ get log ( ) : Log {
26
27
if ( ! logs [ this . namespace ] ) {
27
28
const debug = this . firestack . _debug ;
28
29
logs [ this . namespace ] = new Log ( this . namespace , debug ) ;
@@ -38,7 +39,7 @@ export class Base extends EventEmitter {
38
39
}
39
40
40
41
// TODO unused - do we need this anymore?
41
- _addToFirestackInstance ( ...methods ) {
42
+ _addToFirestackInstance ( ...methods : Array < string > ) {
42
43
methods . forEach ( name => {
43
44
this . firestack [ name ] = this [ name ] . bind ( this ) ;
44
45
} )
@@ -47,15 +48,17 @@ export class Base extends EventEmitter {
47
48
/**
48
49
* app instance
49
50
**/
50
- get app ( ) {
51
+ get app ( ) : Object {
51
52
return this . firestack . app ;
52
53
}
53
54
54
- whenReady ( fn ) {
55
- return this . firestack . configurePromise . then ( fn ) ;
55
+ whenReady ( promise : Promise < * > ) : Promise < * > {
56
+ return this . firestack . configurePromise . then ( ( result ) => {
57
+ return promise ;
58
+ } ) ;
56
59
}
57
60
58
- get namespace ( ) {
61
+ get namespace ( ) : string {
59
62
return 'firestack:base' ;
60
63
}
61
64
@@ -88,25 +91,21 @@ export class Base extends EventEmitter {
88
91
}
89
92
90
93
export class ReferenceBase extends Base {
91
- constructor ( firestack , path ) {
94
+ constructor ( firestack : Object , path : Array < string > | string ) {
92
95
super ( firestack ) ;
93
96
94
- this . path = Array . isArray ( path ) ?
95
- path :
96
- ( typeof path == 'string' ?
97
- [ path ] : [ ] ) ;
97
+ this . path = Array . isArray ( path ) ? path : ( typeof path == 'string' ? [ path ] : [ ] ) ;
98
98
99
99
// sanitize path, just in case
100
- this . path = this . path
101
- . filter ( str => str !== "" ) ;
100
+ this . path = this . path . filter ( str => str !== '' ) ;
102
101
}
103
102
104
- get key ( ) {
103
+ get key ( ) : string {
105
104
const path = this . path ;
106
105
return path . length === 0 ? '/' : path [ path . length - 1 ] ;
107
106
}
108
107
109
- pathToString ( ) {
108
+ pathToString ( ) : string {
110
109
let path = this . path ;
111
110
let pathStr = ( path . length > 0 ? path . join ( '/' ) : '/' ) ;
112
111
if ( pathStr [ 0 ] != '/' ) {
0 commit comments