-
Notifications
You must be signed in to change notification settings - Fork 948
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
Conversation
0956fa7
to
2f4f21e
Compare
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.
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)) { |
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.
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.
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.
Yeah, I see what you mean. Would commenting the source of errors in the catch()
block be helpful in this case?
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.
Probably not necessary, but wouldn't hurt (I leave it up to you. 😄 )
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.
LGTM. Thanks!
); | ||
break; | ||
} catch (error) { | ||
if (isDocumentChangeMissingError(error)) { |
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.
Probably not necessary, but wouldn't hurt (I leave it up to you. 😄 )
No description provided.