File tree 3 files changed +14
-8
lines changed 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @firebase/firestore ' : patch
3
+ ---
4
+
5
+ Refactor Firestore client instantiation. This prepares for future features that require client to restart.
Original file line number Diff line number Diff line change @@ -656,11 +656,9 @@ function readDocumentViaSnapshotListener(
656
656
) : Promise < void > {
657
657
const wrappedObserver = new AsyncObserver ( {
658
658
next : ( snap : ViewSnapshot ) => {
659
- // No further messages should be processed.
660
- wrappedObserver . mute ( ) ;
661
-
662
- // Remove query first before passing event to user to avoid
659
+ // Mute and remove query first before passing event to user to avoid
663
660
// user actions affecting the now stale query.
661
+ wrappedObserver . mute ( ) ;
664
662
asyncQueue . enqueueAndForget ( ( ) =>
665
663
eventManagerUnlisten ( eventManager , listener )
666
664
) ;
@@ -757,11 +755,9 @@ function executeQueryViaSnapshotListener(
757
755
) : Promise < void > {
758
756
const wrappedObserver = new AsyncObserver < ViewSnapshot > ( {
759
757
next : snapshot => {
760
- // No further messages should be processed.
761
- wrappedObserver . mute ( ) ;
762
-
763
- // Remove query first before passing event to user to avoid
758
+ // Mute and remove query first before passing event to user to avoid
764
759
// user actions affecting the now stale query.
760
+ wrappedObserver . mute ( ) ;
765
761
asyncQueue . enqueueAndForget ( ( ) =>
766
762
eventManagerUnlisten ( eventManager , listener )
767
763
) ;
Original file line number Diff line number Diff line change @@ -134,13 +134,18 @@ export class Firestore implements FirestoreService {
134
134
}
135
135
136
136
_delete ( ) : Promise < void > {
137
+ // The `_terminateTask` must be assigned future that completes when
138
+ // terminate is complete. The existence of this future puts SDK in state
139
+ // that will not accept further API interaction.
137
140
if ( this . _terminateTask === 'notTerminated' ) {
138
141
this . _terminateTask = this . _terminate ( ) ;
139
142
}
140
143
return this . _terminateTask ;
141
144
}
142
145
143
146
async _restart ( ) : Promise < void > {
147
+ // The `_terminateTask` must equal 'notTerminated' after restart to
148
+ // signal that client is in a state that accepts API calls.
144
149
if ( this . _terminateTask === 'notTerminated' ) {
145
150
await this . _terminate ( ) ;
146
151
} else {
You can’t perform that action at this time.
0 commit comments