@@ -11,7 +11,13 @@ const FirestackModuleEvt = new NativeEventEmitter(FirestackModule);
11
11
12
12
const logs = { } ;
13
13
14
+ // single event emitter for all classes extending base
15
+ // TODO
16
+ // const EE = new EventEmitter();
17
+
14
18
type FirestackOptions = { } ;
19
+
20
+ // TODO cleanup
15
21
export class Base extends EventEmitter {
16
22
constructor ( firestack : Object , options : FirestackOptions = { } ) {
17
23
super ( ) ;
@@ -22,12 +28,10 @@ export class Base extends EventEmitter {
22
28
this . options = Object . assign ( { } , firestack . options , options ) ;
23
29
}
24
30
31
+
25
32
// Logger
26
33
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 ) ;
31
35
return logs [ this . namespace ] ;
32
36
}
33
37
@@ -40,9 +44,9 @@ export class Base extends EventEmitter {
40
44
41
45
// TODO unused - do we need this anymore?
42
46
_addToFirestackInstance ( ...methods : Array < string > ) {
43
- methods . forEach ( name => {
47
+ methods . forEach ( ( name ) => {
44
48
this . firestack [ name ] = this [ name ] . bind ( this ) ;
45
- } )
49
+ } ) ;
46
50
}
47
51
48
52
/**
@@ -75,7 +79,7 @@ export class Base extends EventEmitter {
75
79
const sub = nativeModule . addListener ( name , cb ) ;
76
80
this . eventHandlers [ name ] = sub ;
77
81
resolve ( sub ) ;
78
- } )
82
+ } ) ;
79
83
}
80
84
81
85
_off ( name ) {
@@ -84,7 +88,7 @@ export class Base extends EventEmitter {
84
88
const subscription = this . eventHandlers [ name ] ;
85
89
subscription . remove ( ) ; // Remove subscription
86
90
delete this . eventHandlers [ name ] ;
87
- resolve ( subscription )
91
+ resolve ( subscription ) ;
88
92
}
89
93
} ) ;
90
94
}
@@ -94,7 +98,7 @@ export class ReferenceBase extends Base {
94
98
constructor ( firestack : Object , path : Array < string > | string ) {
95
99
super ( firestack ) ;
96
100
97
- this . path = Array . isArray ( path ) ? path : ( typeof path == 'string' ? [ path ] : [ ] ) ;
101
+ this . path = Array . isArray ( path ) ? path : ( typeof path === 'string' ? [ path ] : [ ] ) ;
98
102
99
103
// sanitize path, just in case
100
104
this . path = this . path . filter ( str => str !== '' ) ;
@@ -106,10 +110,10 @@ export class ReferenceBase extends Base {
106
110
}
107
111
108
112
pathToString ( ) : string {
109
- let path = this . path ;
113
+ const path = this . path ;
110
114
let pathStr = ( path . length > 0 ? path . join ( '/' ) : '/' ) ;
111
115
if ( pathStr [ 0 ] != '/' ) {
112
- pathStr = `/${ pathStr } `
116
+ pathStr = `/${ pathStr } ` ;
113
117
}
114
118
return pathStr ;
115
119
}
0 commit comments