File tree 2 files changed +14
-10
lines changed 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,19 @@ export type TargetId = number;
30
30
// they're strings. We should probably (de-)serialize to a common internal type.
31
31
export type ProtoByteString = Uint8Array | string ;
32
32
33
- /** Describes the online state of the Firestore client */
33
+ /**
34
+ * Describes the online state of the Firestore client. Note that this does not
35
+ * indicate whether or not the remote store is trying to connect or not. This is
36
+ * primarily used by the View / EventManager code to change their behavior while
37
+ * offline (e.g. get() calls shouldn't wait for data from the server and
38
+ * snapshot events should set metadata.isFromCache=true).
39
+ */
34
40
export enum OnlineState {
35
41
/**
36
42
* The Firestore client is in an unknown online state. This means the client
37
43
* is either not actively trying to establish a connection or it is currently
38
44
* trying to establish a connection, but it has not succeeded or failed yet.
45
+ * Higher-level components should not operate in offline mode.
39
46
*/
40
47
Unknown ,
41
48
@@ -47,9 +54,9 @@ export enum OnlineState {
47
54
Healthy ,
48
55
49
56
/**
50
- * The client considers itself offline. It is either trying to establish a
51
- * connection but failing, or it has been explicitly marked offline via a call
52
- * to disableNetwork() .
57
+ * The client is either trying to establish a connection but failing, or it
58
+ * has been explicitly marked offline via a call to disableNetwork().
59
+ * Higher-level components should operate in offline mode .
53
60
*/
54
61
Failed
55
62
}
Original file line number Diff line number Diff line change @@ -243,16 +243,15 @@ export class RemoteStore {
243
243
*/
244
244
disableNetwork ( ) : Promise < void > {
245
245
// Set the OnlineState to failed so get()'s return from cache, etc.
246
- return this . disableNetworkInternal ( OnlineState . Failed ) ;
246
+ this . disableNetworkInternal ( OnlineState . Failed ) ;
247
+ return Promise . resolve ( ) ;
247
248
}
248
249
249
250
/**
250
251
* Disables the network, setting the OnlineState to the specified
251
252
* targetOnlineState.
252
253
*/
253
- private disableNetworkInternal (
254
- targetOnlineState : OnlineState
255
- ) : Promise < void > {
254
+ private disableNetworkInternal ( targetOnlineState : OnlineState ) : void {
256
255
// NOTE: We're guaranteed not to get any further events from these streams (not even a close
257
256
// event).
258
257
this . watchStream . stop ( ) ;
@@ -265,8 +264,6 @@ export class RemoteStore {
265
264
this . watchStream = null ;
266
265
267
266
this . updateOnlineState ( targetOnlineState ) ;
268
-
269
- return Promise . resolve ( ) ;
270
267
}
271
268
272
269
shutdown ( ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments