Skip to content

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

Merged
merged 6 commits into from
Dec 14, 2017

Conversation

gsoltis
Copy link

@gsoltis gsoltis commented Dec 14, 2017

Tried to clarify OnlineState comments a little. Also removed the Promise<void> return from disableNetworkInternal(), since it operates synchronously and was routinely being ignored anyways. Public API of RemoteStore remains unchanged.

it('Removing default listener removes non-default listener that loads all data', function(
done
) {
it('Removing default listener removes non-default listener that loads all data', function(done) {
Copy link
Contributor

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.

Copy link
Author

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 in yarn.lock was updated most recently here: #268

Copy link
Contributor

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?

/**
* 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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).

Copy link
Author

Choose a reason for hiding this comment

The 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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).

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.")

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple tweaks.

* to disableNetwork().
* The client is either trying to establish a connection but failing, or it
* has been explicitly marked offline via a call to disableNetwork().
* Higher-level components should not operate in offline mode.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the opposite of correct now. :-P

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yeah, cut-and-paste fail.

private disableNetworkInternal(
targetOnlineState: OnlineState
): Promise<void> {
private disableNetworkInternal(targetOnlineState: OnlineState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explicitly declare the return type to be void now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mikelehen
Copy link
Contributor

👍

@mikelehen mikelehen assigned gsoltis and unassigned mikelehen Dec 14, 2017
@gsoltis gsoltis merged commit 8f62706 into firestore-api-changes Dec 14, 2017
@jshcrowthe jshcrowthe deleted the make_disable_internal_sync branch April 16, 2018 21:57
@firebase firebase locked and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants