@@ -121,12 +121,45 @@ export abstract class ComponentProvider {
121
121
}
122
122
123
123
protected abstract createSharedClientState ( ) : SharedClientState ;
124
+
124
125
protected abstract createPersistence ( ) : Persistence ;
126
+
125
127
protected abstract createGarbageCollectionScheduler ( ) : GarbageCollectionScheduler | null ;
126
- protected abstract createLocalStore ( ) : LocalStore ;
127
- protected abstract createRemoteStore ( ) : RemoteStore ;
128
- protected abstract createSyncEngine ( ) : SyncEngine ;
129
- protected abstract createEventManager ( ) : EventManager ;
128
+
129
+ protected createLocalStore ( ) : LocalStore {
130
+ return new LocalStore (
131
+ this . persistence ,
132
+ new IndexFreeQueryEngine ( ) ,
133
+ this . initialUser
134
+ ) ;
135
+ }
136
+ protected createSyncEngine ( ) : SyncEngine {
137
+ return new SyncEngine (
138
+ this . localStore ,
139
+ this . remoteStore ,
140
+ this . sharedClientState ,
141
+ this . initialUser ,
142
+ this . maxConcurrentLimboResolutions
143
+ ) ;
144
+ }
145
+
146
+ protected createEventManager ( ) : EventManager {
147
+ return new EventManager ( this . syncEngine ) ;
148
+ }
149
+
150
+ protected createRemoteStore ( ) : RemoteStore {
151
+ return new RemoteStore (
152
+ this . localStore ,
153
+ this . datastore ,
154
+ this . asyncQueue ,
155
+ onlineState =>
156
+ this . syncEngine . applyOnlineStateChange (
157
+ onlineState ,
158
+ OnlineStateSource . RemoteStore
159
+ ) ,
160
+ this . platform . newConnectivityMonitor ( )
161
+ ) ;
162
+ }
130
163
131
164
abstract clearPersistence ( databaseId : DatabaseInfo ) : Promise < void > ;
132
165
}
@@ -135,10 +168,6 @@ export abstract class ComponentProvider {
135
168
* Provides all components needed for Firestore with IndexedDB persistence.
136
169
*/
137
170
export class IndexedDbComponentProvider extends ComponentProvider {
138
- protected createEventManager ( ) : EventManager {
139
- return new EventManager ( this . syncEngine ) ;
140
- }
141
-
142
171
protected createGarbageCollectionScheduler ( ) : GarbageCollectionScheduler | null {
143
172
debugAssert (
144
173
this . persistence instanceof IndexedDbPersistence ,
@@ -149,14 +178,6 @@ export class IndexedDbComponentProvider extends ComponentProvider {
149
178
return new LruScheduler ( garbageCollector , this . asyncQueue ) ;
150
179
}
151
180
152
- protected createLocalStore ( ) : LocalStore {
153
- return new LocalStore (
154
- this . persistence ,
155
- new IndexFreeQueryEngine ( ) ,
156
- this . initialUser
157
- ) ;
158
- }
159
-
160
181
protected createPersistence ( ) : Persistence {
161
182
debugAssert (
162
183
this . persistenceSettings . durable ,
@@ -183,20 +204,6 @@ export class IndexedDbComponentProvider extends ComponentProvider {
183
204
} ) ;
184
205
}
185
206
186
- protected createRemoteStore ( ) : RemoteStore {
187
- return new RemoteStore (
188
- this . localStore ,
189
- this . datastore ,
190
- this . asyncQueue ,
191
- onlineState =>
192
- this . syncEngine . applyOnlineStateChange (
193
- onlineState ,
194
- OnlineStateSource . RemoteStore
195
- ) ,
196
- this . platform . newConnectivityMonitor ( )
197
- ) ;
198
- }
199
-
200
207
protected createSharedClientState ( ) : SharedClientState {
201
208
debugAssert (
202
209
this . persistenceSettings . durable ,
@@ -224,16 +231,6 @@ export class IndexedDbComponentProvider extends ComponentProvider {
224
231
return new MemorySharedClientState ( ) ;
225
232
}
226
233
227
- protected createSyncEngine ( ) : SyncEngine {
228
- return new SyncEngine (
229
- this . localStore ,
230
- this . remoteStore ,
231
- this . sharedClientState ,
232
- this . initialUser ,
233
- this . maxConcurrentLimboResolutions
234
- ) ;
235
- }
236
-
237
234
clearPersistence ( databaseInfo : DatabaseInfo ) : Promise < void > {
238
235
const persistenceKey = IndexedDbPersistence . buildStoragePrefix (
239
236
databaseInfo
@@ -259,22 +256,10 @@ export class MemoryComponentProvider extends ComponentProvider {
259
256
super ( ) ;
260
257
}
261
258
262
- protected createEventManager ( ) : EventManager {
263
- return new EventManager ( this . syncEngine ) ;
264
- }
265
-
266
259
protected createGarbageCollectionScheduler ( ) : GarbageCollectionScheduler | null {
267
260
return null ;
268
261
}
269
262
270
- protected createLocalStore ( ) : LocalStore {
271
- return new LocalStore (
272
- this . persistence ,
273
- new IndexFreeQueryEngine ( ) ,
274
- this . initialUser
275
- ) ;
276
- }
277
-
278
263
protected createPersistence ( ) : Persistence {
279
264
debugAssert (
280
265
! this . persistenceSettings . durable ,
@@ -283,34 +268,10 @@ export class MemoryComponentProvider extends ComponentProvider {
283
268
return new MemoryPersistence ( this . clientId , this . referenceDelegateFactory ) ;
284
269
}
285
270
286
- protected createRemoteStore ( ) : RemoteStore {
287
- return new RemoteStore (
288
- this . localStore ,
289
- this . datastore ,
290
- this . asyncQueue ,
291
- onlineState =>
292
- this . syncEngine . applyOnlineStateChange (
293
- onlineState ,
294
- OnlineStateSource . RemoteStore
295
- ) ,
296
- this . platform . newConnectivityMonitor ( )
297
- ) ;
298
- }
299
-
300
271
protected createSharedClientState ( ) : SharedClientState {
301
272
return new MemorySharedClientState ( ) ;
302
273
}
303
274
304
- protected createSyncEngine ( ) : SyncEngine {
305
- return new SyncEngine (
306
- this . localStore ,
307
- this . remoteStore ,
308
- this . sharedClientState ,
309
- this . initialUser ,
310
- this . maxConcurrentLimboResolutions
311
- ) ;
312
- }
313
-
314
275
clearPersistence ( ) : never {
315
276
throw new FirestoreError (
316
277
Code . FAILED_PRECONDITION ,
0 commit comments