@@ -11,7 +11,13 @@ const FirestackModuleEvt = new NativeEventEmitter(FirestackModule);
1111
1212const logs = { } ;
1313
14+ // single event emitter for all classes extending base
15+ // TODO
16+ // const EE = new EventEmitter();
17+
1418type FirestackOptions = { } ;
19+
20+ // TODO cleanup
1521export class Base extends EventEmitter {
1622 constructor ( firestack : Object , options : FirestackOptions = { } ) {
1723 super ( ) ;
@@ -22,12 +28,10 @@ export class Base extends EventEmitter {
2228 this . options = Object . assign ( { } , firestack . options , options ) ;
2329 }
2430
31+
2532 // Logger
2633 get log ( ) : Log {
27- if ( ! logs [ this . namespace ] ) {
28- const debug = this . firestack . _debug ;
29- logs [ this . namespace ] = new Log ( this . namespace , debug ) ;
30- }
34+ if ( ! logs [ this . namespace ] ) logs [ this . namespace ] = new Log ( this . namespace , this . firestack . _debug ) ;
3135 return logs [ this . namespace ] ;
3236 }
3337
@@ -40,9 +44,9 @@ export class Base extends EventEmitter {
4044
4145 // TODO unused - do we need this anymore?
4246 _addToFirestackInstance ( ...methods : Array < string > ) {
43- methods . forEach ( name => {
47+ methods . forEach ( ( name ) => {
4448 this . firestack [ name ] = this [ name ] . bind ( this ) ;
45- } )
49+ } ) ;
4650 }
4751
4852 /**
@@ -75,7 +79,7 @@ export class Base extends EventEmitter {
7579 const sub = nativeModule . addListener ( name , cb ) ;
7680 this . eventHandlers [ name ] = sub ;
7781 resolve ( sub ) ;
78- } )
82+ } ) ;
7983 }
8084
8185 _off ( name ) {
@@ -84,7 +88,7 @@ export class Base extends EventEmitter {
8488 const subscription = this . eventHandlers [ name ] ;
8589 subscription . remove ( ) ; // Remove subscription
8690 delete this . eventHandlers [ name ] ;
87- resolve ( subscription )
91+ resolve ( subscription ) ;
8892 }
8993 } ) ;
9094 }
@@ -94,7 +98,7 @@ export class ReferenceBase extends Base {
9498 constructor ( firestack : Object , path : Array < string > | string ) {
9599 super ( firestack ) ;
96100
97- this . path = Array . isArray ( path ) ? path : ( typeof path == 'string' ? [ path ] : [ ] ) ;
101+ this . path = Array . isArray ( path ) ? path : ( typeof path === 'string' ? [ path ] : [ ] ) ;
98102
99103 // sanitize path, just in case
100104 this . path = this . path . filter ( str => str !== '' ) ;
@@ -106,10 +110,10 @@ export class ReferenceBase extends Base {
106110 }
107111
108112 pathToString ( ) : string {
109- let path = this . path ;
113+ const path = this . path ;
110114 let pathStr = ( path . length > 0 ? path . join ( '/' ) : '/' ) ;
111115 if ( pathStr [ 0 ] != '/' ) {
112- pathStr = `/${ pathStr } `
116+ pathStr = `/${ pathStr } ` ;
113117 }
114118 return pathStr ;
115119 }
0 commit comments