Skip to content

Commit 4324f54

Browse files
Revert "Maybe reduce size"
This reverts commit 9725015.
1 parent 9725015 commit 4324f54

File tree

1 file changed

+76
-37
lines changed

1 file changed

+76
-37
lines changed

packages/firestore/src/core/component_provider.ts

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -121,45 +121,12 @@ export abstract class ComponentProvider {
121121
}
122122

123123
protected abstract createSharedClientState(): SharedClientState;
124-
125124
protected abstract createPersistence(): Persistence;
126-
127125
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;
163130

164131
abstract clearPersistence(databaseId: DatabaseInfo): Promise<void>;
165132
}
@@ -168,6 +135,10 @@ export abstract class ComponentProvider {
168135
* Provides all components needed for Firestore with IndexedDB persistence.
169136
*/
170137
export class IndexedDbComponentProvider extends ComponentProvider {
138+
protected createEventManager(): EventManager {
139+
return new EventManager(this.syncEngine);
140+
}
141+
171142
protected createGarbageCollectionScheduler(): GarbageCollectionScheduler | null {
172143
debugAssert(
173144
this.persistence instanceof IndexedDbPersistence,
@@ -178,6 +149,14 @@ export class IndexedDbComponentProvider extends ComponentProvider {
178149
return new LruScheduler(garbageCollector, this.asyncQueue);
179150
}
180151

152+
protected createLocalStore(): LocalStore {
153+
return new LocalStore(
154+
this.persistence,
155+
new IndexFreeQueryEngine(),
156+
this.initialUser
157+
);
158+
}
159+
181160
protected createPersistence(): Persistence {
182161
debugAssert(
183162
this.persistenceSettings.durable,
@@ -204,6 +183,20 @@ export class IndexedDbComponentProvider extends ComponentProvider {
204183
});
205184
}
206185

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+
207200
protected createSharedClientState(): SharedClientState {
208201
debugAssert(
209202
this.persistenceSettings.durable,
@@ -231,6 +224,16 @@ export class IndexedDbComponentProvider extends ComponentProvider {
231224
return new MemorySharedClientState();
232225
}
233226

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+
234237
clearPersistence(databaseInfo: DatabaseInfo): Promise<void> {
235238
const persistenceKey = IndexedDbPersistence.buildStoragePrefix(
236239
databaseInfo
@@ -256,10 +259,22 @@ export class MemoryComponentProvider extends ComponentProvider {
256259
super();
257260
}
258261

262+
protected createEventManager(): EventManager {
263+
return new EventManager(this.syncEngine);
264+
}
265+
259266
protected createGarbageCollectionScheduler(): GarbageCollectionScheduler | null {
260267
return null;
261268
}
262269

270+
protected createLocalStore(): LocalStore {
271+
return new LocalStore(
272+
this.persistence,
273+
new IndexFreeQueryEngine(),
274+
this.initialUser
275+
);
276+
}
277+
263278
protected createPersistence(): Persistence {
264279
debugAssert(
265280
!this.persistenceSettings.durable,
@@ -268,10 +283,34 @@ export class MemoryComponentProvider extends ComponentProvider {
268283
return new MemoryPersistence(this.clientId, this.referenceDelegateFactory);
269284
}
270285

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+
271300
protected createSharedClientState(): SharedClientState {
272301
return new MemorySharedClientState();
273302
}
274303

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+
275314
clearPersistence(): never {
276315
throw new FirestoreError(
277316
Code.FAILED_PRECONDITION,

0 commit comments

Comments
 (0)