@@ -447,6 +447,39 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
447447 return deferred . promise ;
448448 }
449449
450+ /**
451+ * Shuts down this Firestore instance.
452+ *
453+ * After shutdown only the `clearPersistence()` method may be used. Any other method
454+ * will throw a `FirestoreError`.
455+ *
456+ * To restart after shutdown, simply create a new instance of FirebaseFirestore with
457+ * `firebase.firestore()`.
458+ *
459+ * Shutdown does not cancel any pending writes and any promises that are awaiting a response
460+ * from the server will not be resolved. If you have persistence enabled, the next time you
461+ * start this instance, it will resume attempting to send these writes to the server.
462+ *
463+ * Note: Under normal circumstances, calling `shutdown()` is not required. This
464+ * method is useful only when you want to force this instance to release all of its resources or
465+ * in combination with `clearPersistence()` to ensure that all local state is destroyed
466+ * between test runs.
467+ *
468+ * @return A promise that is resolved when the instance has been successfully shut down.
469+ */
470+ // TODO(b/135755126): make this public.
471+ _shutdown ( ) : Promise < void > {
472+ ( this . app as _FirebaseApp ) . _removeServiceInstance (
473+ 'firestore'
474+ ) ;
475+ return this . INTERNAL . delete ( ) ;
476+ }
477+
478+ get _isShutdown ( ) : boolean {
479+ this . ensureClientConfigured ( ) ;
480+ return this . _firestoreClient ! . clientShutdown ;
481+ }
482+
450483 ensureClientConfigured ( ) : FirestoreClient {
451484 if ( ! this . _firestoreClient ) {
452485 // Kick off starting the client but don't actually wait for it.
@@ -538,44 +571,11 @@ export class Firestore implements firestore.FirebaseFirestore, FirebaseService {
538571 }
539572
540573 INTERNAL = {
541- // TODO(b/135755126): Make this public
542574 delete : async ( ) : Promise < void > => {
543575 // The client must be initalized to ensure that all subsequent API usage
544576 // throws an exception.
545577 this . ensureClientConfigured ( ) ;
546578 await this . _firestoreClient ! . shutdown ( ) ;
547- } ,
548-
549- /**
550- * Shuts down this Firestore instance.
551- *
552- * After shutdown only the `clearPersistence()` method may be used. Any other method
553- * will throw an `FirestoreError`.
554- *
555- * To restart after shutdown, simply create a new instance of FirebaseFirestore with
556- * `Firebase.firestore()`.
557- *
558- * Shutdown does not cancel any pending writes and any promises that are awaiting a response
559- * from the server will not be resolved. The next time you start this instance,
560- * it will resume attempting to send these writes to the server.
561- *
562- * Note: Under normal circumstances, calling `shutdown()` is not required. This
563- * method is useful only when you want to force this instance to release all of its resources or
564- * in combination with `clearPersistence()` to ensure that all local state is destroyed
565- * between test runs.
566- *
567- * @return A promise that is resolved when the instance has been successfully shut down.
568- */
569- // TODO(b/135755126): make this public.
570- shutdown : ( ) : Promise < void > => {
571- ( this . _config . firebaseApp as _FirebaseApp ) . _removeServiceInstance (
572- 'firestore'
573- ) ;
574- return this . INTERNAL . delete ( ) ;
575- } ,
576-
577- isShutdown : ( ) : boolean => {
578- return this . _firestoreClient ! . clientShutdown ;
579579 }
580580 } ;
581581
0 commit comments