Skip to content

Refactor Transaction and SyncEngine to use async/await #1983

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 7 commits into from
Jul 18, 2019

Conversation

thebrianchen
Copy link

No description provided.

Brian Chen added 2 commits July 15, 2019 16:46
# This is the 1st commit message:

Refactor Transactions and SyncEngine

# This is the commit message #2:

undo transaction test

# This is the commit message #3:

fix failed build linter check

# This is the commit message #4:

fix runTransaction return
@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff Jul 17, 2019
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.

This mostly looks good and is nice clean up, but I think we perhaps undid a performance optimization (letting multiple promises execute in parallel) in one spot.

In general, I think this is 80% nice cleanup, but ~20% just code churn (the resulting code isn't particularly more readable than the prior code).

);
break;
} catch (error) {
if (isDocumentChangeMissingError(error)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm. I think the prior code was a bit more precisely correct in that it was clear that the DocumentChangeMissingError would come from the getNewDocumentChanges() call, whereas now it could (theoretically) come from createSynthesizedRemoteEventForCurrentChange() or emitNewSnapsAndNotifyLocalStore().

It's probably fine, but I'm noticing that the promise chaining code is in some ways better... though the new code is perhaps more readable since the many line .then(..., ...) construct is probably easy to misread.

Anyway, this is probably good. I'm just thinking out loud.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I see what you mean. Would commenting the source of errors in the catch() block be helpful in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not necessary, but wouldn't hurt (I leave it up to you. 😄 )

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. Thanks!

);
break;
} catch (error) {
if (isDocumentChangeMissingError(error)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not necessary, but wouldn't hurt (I leave it up to you. 😄 )

@mikelehen mikelehen assigned thebrianchen and unassigned mikelehen Jul 18, 2019
@thebrianchen thebrianchen merged commit 9173c90 into master Jul 18, 2019
@thebrianchen thebrianchen deleted the bc/await-sync branch July 18, 2019 18:03
@firebase firebase locked and limited conversation to collaborators Oct 9, 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