File tree Expand file tree Collapse file tree 5 files changed +25
-17
lines changed Expand file tree Collapse file tree 5 files changed +25
-17
lines changed Original file line number Diff line number Diff line change @@ -124,3 +124,14 @@ export async function removeFirestoreClient(
124
124
) ;
125
125
}
126
126
}
127
+
128
+ /**
129
+ * Removes all components associated with the provided instance;
130
+ */
131
+ export async function removeComponents ( firestore : Firestore ) : Promise < void > {
132
+ const firestoreClientPromise = firestoreClientInstances . get ( firestore ) ;
133
+ if ( firestoreClientPromise ) {
134
+ firestoreClientInstances . delete ( firestore ) ;
135
+ return ( await firestoreClientPromise ) . terminate ( ) ;
136
+ }
137
+ }
Original file line number Diff line number Diff line change @@ -40,8 +40,7 @@ import {
40
40
} from '../../../src/local/indexeddb_persistence' ;
41
41
import {
42
42
getFirestoreClient ,
43
- initializeFirestoreClient ,
44
- removeFirestoreClient
43
+ initializeFirestoreClient , removeComponents
45
44
} from './components' ;
46
45
47
46
/**
@@ -71,7 +70,7 @@ export class Firestore extends LiteFirestore
71
70
72
71
async _terminate ( ) : Promise < void > {
73
72
await super . _terminate ( ) ;
74
- await removeFirestoreClient ( this ) ;
73
+ await removeComponents ( this ) ;
75
74
}
76
75
}
77
76
Original file line number Diff line number Diff line change 18
18
import {
19
19
Datastore ,
20
20
newDatastore ,
21
- terminateDatastore
22
21
} from '../../../src/remote/datastore' ;
23
22
import { newConnection } from '../../../src/platform/connection' ;
24
23
import { newSerializer } from '../../../src/platform/serializer' ;
@@ -66,13 +65,12 @@ export function getDatastore(firestore: Firestore): Promise<Datastore> {
66
65
}
67
66
68
67
/**
69
- * Removes and terminates the Datastore for the given instance if it has
70
- * been started.
68
+ * Removes all components associated with the provided instance;
71
69
*/
72
- export async function removeDatastore ( firestore : Firestore ) : Promise < void > {
73
- const datastore = await datastoreInstances . get ( firestore ) ;
74
- if ( datastore ) {
70
+ export async function removeComponents ( firestore : Firestore ) : Promise < void > {
71
+ const datastorePromise = await datastoreInstances . get ( firestore ) ;
72
+ if ( datastorePromise ) {
75
73
datastoreInstances . delete ( firestore ) ;
76
- return terminateDatastore ( datastore ) ;
74
+ return ( await datastorePromise ) . termiate ( ) ;
77
75
}
78
76
}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import {
29
29
FirebaseCredentialsProvider
30
30
} from '../../../src/api/credentials' ;
31
31
import { cast } from './util' ;
32
- import { removeDatastore } from './components' ;
32
+ import { removeComponents } from './components' ;
33
33
import { debugAssert } from '../../../src/util/assert' ;
34
34
35
35
/**
@@ -112,7 +112,7 @@ export class Firestore
112
112
*/
113
113
protected _terminate ( ) : Promise < void > {
114
114
debugAssert ( ! this . _terminated , 'Cannot invoke _terminate() more than once' ) ;
115
- return removeDatastore ( this ) ;
115
+ return removeComponents ( this ) ;
116
116
}
117
117
118
118
// TODO(firestoreexp): `deleteApp()` should call the delete method above,
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ import { Query } from '../core/query';
48
48
*/
49
49
export abstract class Datastore {
50
50
abstract start ( connection : Connection ) : void ;
51
+ abstract termiate ( ) : Promise < void > ;
51
52
}
52
53
53
54
/**
@@ -118,6 +119,10 @@ class DatastoreImpl extends Datastore {
118
119
throw error ;
119
120
} ) ;
120
121
}
122
+
123
+ async termiate ( ) : Promise < void > {
124
+ this . terminated = false ;
125
+ }
121
126
}
122
127
123
128
// TODO(firestorexp): Make sure there is only one Datastore instance per
@@ -230,8 +235,3 @@ export function newPersistentWatchStream(
230
235
listener
231
236
) ;
232
237
}
233
-
234
- export function terminateDatastore ( datastore : Datastore ) : void {
235
- const datastoreImpl = debugCast ( datastore , DatastoreImpl ) ;
236
- datastoreImpl . terminated = true ;
237
- }
You can’t perform that action at this time.
0 commit comments