@@ -121,45 +121,12 @@ export abstract class ComponentProvider {
121
121
}
122
122
123
123
protected abstract createSharedClientState ( ) : SharedClientState ;
124
-
125
124
protected abstract createPersistence ( ) : Persistence ;
126
-
127
125
protected abstract createGarbageCollectionScheduler ( ) : GarbageCollectionScheduler | null ;
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
- }
126
+ protected abstract createLocalStore ( ) : LocalStore ;
127
+ protected abstract createRemoteStore ( ) : RemoteStore ;
128
+ protected abstract createSyncEngine ( ) : SyncEngine ;
129
+ protected abstract createEventManager ( ) : EventManager ;
163
130
164
131
abstract clearPersistence ( databaseId : DatabaseInfo ) : Promise < void > ;
165
132
}
@@ -168,6 +135,10 @@ export abstract class ComponentProvider {
168
135
* Provides all components needed for Firestore with IndexedDB persistence.
169
136
*/
170
137
export class IndexedDbComponentProvider extends ComponentProvider {
138
+ protected createEventManager ( ) : EventManager {
139
+ return new EventManager ( this . syncEngine ) ;
140
+ }
141
+
171
142
protected createGarbageCollectionScheduler ( ) : GarbageCollectionScheduler | null {
172
143
debugAssert (
173
144
this . persistence instanceof IndexedDbPersistence ,
@@ -178,6 +149,14 @@ export class IndexedDbComponentProvider extends ComponentProvider {
178
149
return new LruScheduler ( garbageCollector , this . asyncQueue ) ;
179
150
}
180
151
152
+ protected createLocalStore ( ) : LocalStore {
153
+ return new LocalStore (
154
+ this . persistence ,
155
+ new IndexFreeQueryEngine ( ) ,
156
+ this . initialUser
157
+ ) ;
158
+ }
159
+
181
160
protected createPersistence ( ) : Persistence {
182
161
debugAssert (
183
162
this . persistenceSettings . durable ,
@@ -204,6 +183,20 @@ export class IndexedDbComponentProvider extends ComponentProvider {
204
183
} ) ;
205
184
}
206
185
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
+
207
200
protected createSharedClientState ( ) : SharedClientState {
208
201
debugAssert (
209
202
this . persistenceSettings . durable ,
@@ -231,6 +224,16 @@ export class IndexedDbComponentProvider extends ComponentProvider {
231
224
return new MemorySharedClientState ( ) ;
232
225
}
233
226
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
+
234
237
clearPersistence ( databaseInfo : DatabaseInfo ) : Promise < void > {
235
238
const persistenceKey = IndexedDbPersistence . buildStoragePrefix (
236
239
databaseInfo
@@ -256,10 +259,22 @@ export class MemoryComponentProvider extends ComponentProvider {
256
259
super ( ) ;
257
260
}
258
261
262
+ protected createEventManager ( ) : EventManager {
263
+ return new EventManager ( this . syncEngine ) ;
264
+ }
265
+
259
266
protected createGarbageCollectionScheduler ( ) : GarbageCollectionScheduler | null {
260
267
return null ;
261
268
}
262
269
270
+ protected createLocalStore ( ) : LocalStore {
271
+ return new LocalStore (
272
+ this . persistence ,
273
+ new IndexFreeQueryEngine ( ) ,
274
+ this . initialUser
275
+ ) ;
276
+ }
277
+
263
278
protected createPersistence ( ) : Persistence {
264
279
debugAssert (
265
280
! this . persistenceSettings . durable ,
@@ -268,10 +283,34 @@ export class MemoryComponentProvider extends ComponentProvider {
268
283
return new MemoryPersistence ( this . clientId , this . referenceDelegateFactory ) ;
269
284
}
270
285
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
+
271
300
protected createSharedClientState ( ) : SharedClientState {
272
301
return new MemorySharedClientState ( ) ;
273
302
}
274
303
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
+
275
314
clearPersistence ( ) : never {
276
315
throw new FirestoreError (
277
316
Code . FAILED_PRECONDITION ,
0 commit comments