-
Notifications
You must be signed in to change notification settings - Fork 940
Make disable internal sync and update notes about OnlineState #380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
15fe79b
223f5eb
a003e01
937fd0f
00956ef
7ffcbc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,17 @@ export type TargetId = number; | |
// they're strings. We should probably (de-)serialize to a common internal type. | ||
export type ProtoByteString = Uint8Array | string; | ||
|
||
/** Describes the online state of the Firestore client */ | ||
/** | ||
* Describes the online state of the Firestore client. Note that this does not | ||
* indicate whether or not the remote store is trying to connect or not. This is | ||
* primarily used for views determining whether or not raise events from cache. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it's more nuanced than "whether or not to raise events from cache"... Maybe: This is primarily used by the View / EventManager code to change their behavior while offline (e.g. get() calls shouldn't wait for data from the server and snapshot events should set metadata.isFromCache=true). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've updated the comments. Take a look. |
||
*/ | ||
export enum OnlineState { | ||
/** | ||
* The Firestore client is in an unknown online state. This means the client | ||
* is either not actively trying to establish a connection or it is currently | ||
* trying to establish a connection, but it has not succeeded or failed yet. | ||
* Events are not raised from cache. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't really true because snapshot listeners always get events from cache (since we'll raise a new event when we get up-to-date server data). |
||
*/ | ||
Unknown, | ||
|
||
|
@@ -49,7 +54,7 @@ export enum OnlineState { | |
/** | ||
* The client considers itself offline. It is either trying to establish a | ||
* connection but failing, or it has been explicitly marked offline via a call | ||
* to disableNetwork(). | ||
* to disableNetwork(). Events will be raised from cache. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per my previous comments, it's more nuanced than this so we should either drop this or rephrase it somehow (like maybe "Higher-level components should operate in offline mode.", but that's not that different than "The client considers itself offline.") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I rephrased this a little, let me know if you think it's correct now. |
||
*/ | ||
Failed | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,16 +243,15 @@ export class RemoteStore { | |
*/ | ||
disableNetwork(): Promise<void> { | ||
// Set the OnlineState to failed so get()'s return from cache, etc. | ||
return this.disableNetworkInternal(OnlineState.Failed); | ||
this.disableNetworkInternal(OnlineState.Failed); | ||
return Promise.resolve(); | ||
} | ||
|
||
/** | ||
* Disables the network, setting the OnlineState to the specified | ||
* targetOnlineState. | ||
*/ | ||
private disableNetworkInternal( | ||
targetOnlineState: OnlineState | ||
): Promise<void> { | ||
private disableNetworkInternal(targetOnlineState: OnlineState) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explicitly declare the return type to be void now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
// NOTE: We're guaranteed not to get any further events from these streams (not even a close | ||
// event). | ||
this.watchStream.stop(); | ||
|
@@ -265,8 +264,6 @@ export class RemoteStore { | |
this.watchStream = null; | ||
|
||
this.updateOnlineState(targetOnlineState); | ||
|
||
return Promise.resolve(); | ||
} | ||
|
||
shutdown(): Promise<void> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you verify you have the correct prettier version (specified by yarn.lock I think) installed and it is making these changes? I think either you don't, or somebody updated yarn.lock without re-running it against the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got version 1.8.2, which is what's specified in
yarn.lock
. Looks like the version inyarn.lock
was updated most recently here: #268There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I do a "yarn prepush" from the root of the repo, it makes a commit that undoes all of these changes... Can you give that a try?