Skip to content
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

Allow user to unlisten to queries after shutdown. #2083

Merged
merged 7 commits into from
Aug 16, 2019

Conversation

wu-hui
Copy link
Contributor

@wu-hui wu-hui commented Aug 14, 2019

No description provided.

@@ -536,7 +536,6 @@ export class FirestoreClient {
}

unlisten(listener: QueryListener): void {
this.verifyNotShutdown();
this.asyncQueue.enqueueAndForget(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This potentially calls into the SyncEngine. I wonder if we should guard this on the shutdown state and not call unlisten if we are shut down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -536,7 +536,10 @@ export class FirestoreClient {
}

unlisten(listener: QueryListener): void {
this.verifyNotShutdown();
// Make unlisten a no-op if client is shut down.
Copy link
Contributor

Choose a reason for hiding this comment

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

Your code is so clear that I think we can remove this comment :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually want to keep it. The reason is FirestoreClient methods generally run verifyNotShutdown before doing anything. This one deviate from that.

I updated the comment to be more clear.

@@ -536,7 +536,10 @@ export class FirestoreClient {
}

unlisten(listener: QueryListener): void {
this.verifyNotShutdown();
// Make unlisten a no-op if client is shut down.
if(this.clientShutdown) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is something going on with your formatter. This should be if (this.clientShutdown)

I would also slightly prefer if you wrote the inverse and removed the early return. Optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's strange, the automated prettier commit did not make into the push somehow..

@wu-hui wu-hui assigned schmidt-sebastian and unassigned wu-hui Aug 15, 2019
@schmidt-sebastian schmidt-sebastian removed their assignment Aug 15, 2019
@wu-hui wu-hui merged commit 2907439 into master Aug 16, 2019
@firebase firebase locked and limited conversation to collaborators Oct 8, 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.

None yet

2 participants