@@ -84,23 +84,28 @@ export class Repo {
84
84
85
85
constructor (
86
86
public repoInfo_ : RepoInfo ,
87
- forceRestClient : boolean ,
87
+ private forceRestClient_ : boolean ,
88
88
public app : FirebaseApp ,
89
- authTokenProvider : AuthTokenProvider
89
+ public authTokenProvider_ : AuthTokenProvider
90
90
) {
91
- this . stats_ = StatsManager . getCollection ( repoInfo_ ) ;
91
+ // This key is intentionally not updated if RepoInfo is later changed or replaced
92
+ this . key = this . repoInfo_ . toURLString ( ) ;
93
+ }
94
+
95
+ start ( ) : void {
96
+ this . stats_ = StatsManager . getCollection ( this . repoInfo_ ) ;
92
97
93
- if ( forceRestClient || beingCrawled ( ) ) {
98
+ if ( this . forceRestClient_ || beingCrawled ( ) ) {
94
99
this . server_ = new ReadonlyRestClient (
95
100
this . repoInfo_ ,
96
101
this . onDataUpdate_ . bind ( this ) ,
97
- authTokenProvider
102
+ this . authTokenProvider_
98
103
) ;
99
104
100
105
// Minor hack: Fire onConnect immediately, since there's no actual connection.
101
106
setTimeout ( this . onConnectStatus_ . bind ( this , true ) , 0 ) ;
102
107
} else {
103
- const authOverride = app . options [ 'databaseAuthVariableOverride' ] ;
108
+ const authOverride = this . app . options [ 'databaseAuthVariableOverride' ] ;
104
109
// Validate authOverride
105
110
if ( typeof authOverride !== 'undefined' && authOverride !== null ) {
106
111
if ( typeof authOverride !== 'object' ) {
@@ -117,25 +122,25 @@ export class Repo {
117
122
118
123
this . persistentConnection_ = new PersistentConnection (
119
124
this . repoInfo_ ,
120
- app . options . appId ,
125
+ this . app . options . appId ,
121
126
this . onDataUpdate_ . bind ( this ) ,
122
127
this . onConnectStatus_ . bind ( this ) ,
123
128
this . onServerInfoUpdate_ . bind ( this ) ,
124
- authTokenProvider ,
129
+ this . authTokenProvider_ ,
125
130
authOverride
126
131
) ;
127
132
128
133
this . server_ = this . persistentConnection_ ;
129
134
}
130
135
131
- authTokenProvider . addTokenChangeListener ( token => {
136
+ this . authTokenProvider_ . addTokenChangeListener ( token => {
132
137
this . server_ . refreshAuthToken ( token ) ;
133
138
} ) ;
134
139
135
140
// In the case of multiple Repos for the same repoInfo (i.e. there are multiple Firebase.Contexts being used),
136
141
// we only want to create one StatsReporter. As such, we'll report stats over the first Repo created.
137
142
this . statsReporter_ = StatsManager . getOrCreateReporter (
138
- repoInfo_ ,
143
+ this . repoInfo_ ,
139
144
( ) => new StatsReporter ( this . stats_ , this . server_ )
140
145
) ;
141
146
@@ -177,9 +182,6 @@ export class Repo {
177
182
this . server_ . unlisten ( query , tag ) ;
178
183
}
179
184
} ) ;
180
-
181
- // This key is intentionally not updated if RepoInfo is later changed or replaced
182
- this . key = this . repoInfo_ . toURLString ( ) ;
183
185
}
184
186
185
187
/**
0 commit comments