@@ -11,8 +11,9 @@ const FirestackModuleEvt = new NativeEventEmitter(FirestackModule);
1111
1212const logs = { } ;
1313
14+ type FirestackOptions = { } ;
1415export class Base extends EventEmitter {
15- constructor ( firestack , options = { } ) {
16+ constructor ( firestack : Object , options : FirestackOptions = { } ) {
1617 super ( ) ;
1718 this . firestack = firestack ;
1819 this . eventHandlers = { } ;
@@ -22,7 +23,7 @@ export class Base extends EventEmitter {
2223 }
2324
2425 // Logger
25- get log ( ) {
26+ get log ( ) : Log {
2627 if ( ! logs [ this . namespace ] ) {
2728 const debug = this . firestack . _debug ;
2829 logs [ this . namespace ] = new Log ( this . namespace , debug ) ;
@@ -38,7 +39,7 @@ export class Base extends EventEmitter {
3839 }
3940
4041 // TODO unused - do we need this anymore?
41- _addToFirestackInstance ( ...methods ) {
42+ _addToFirestackInstance ( ...methods : Array < string > ) {
4243 methods . forEach ( name => {
4344 this . firestack [ name ] = this [ name ] . bind ( this ) ;
4445 } )
@@ -47,15 +48,17 @@ export class Base extends EventEmitter {
4748 /**
4849 * app instance
4950 **/
50- get app ( ) {
51+ get app ( ) : Object {
5152 return this . firestack . app ;
5253 }
5354
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+ } ) ;
5659 }
5760
58- get namespace ( ) {
61+ get namespace ( ) : string {
5962 return 'firestack:base' ;
6063 }
6164
@@ -88,25 +91,21 @@ export class Base extends EventEmitter {
8891}
8992
9093export class ReferenceBase extends Base {
91- constructor ( firestack , path ) {
94+ constructor ( firestack : Object , path : Array < string > | string ) {
9295 super ( firestack ) ;
9396
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 ] : [ ] ) ;
9898
9999 // sanitize path, just in case
100- this . path = this . path
101- . filter ( str => str !== "" ) ;
100+ this . path = this . path . filter ( str => str !== '' ) ;
102101 }
103102
104- get key ( ) {
103+ get key ( ) : string {
105104 const path = this . path ;
106105 return path . length === 0 ? '/' : path [ path . length - 1 ] ;
107106 }
108107
109- pathToString ( ) {
108+ pathToString ( ) : string {
110109 let path = this . path ;
111110 let pathStr = ( path . length > 0 ? path . join ( '/' ) : '/' ) ;
112111 if ( pathStr [ 0 ] != '/' ) {
0 commit comments