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

Firestore Transactions #827

Merged
merged 27 commits into from
Mar 5, 2018
Merged

Firestore Transactions #827

merged 27 commits into from
Mar 5, 2018

Conversation

Salakar
Copy link
Contributor

@Salakar Salakar commented Feb 11, 2018

Adds firestore transaction support for both Android & iOS

@HofmannZ
Copy link

HofmannZ commented Feb 12, 2018

@Salakar, I see you use WIP on most PRs. We do that too but use this nice little integration: https://github.com/apps/wip. As long as 'WIP' is in the title you cannot merge the PR. Thought you might find it useful, cheers!

@Salakar
Copy link
Contributor Author

Salakar commented Feb 12, 2018

@HofmannZ Interesting! Thanks for that :)

*/
export default class TransactionHandler {
_firestore: Firestore;
_transactionListener: Function;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason to store this as we never unsubscribe from the listener?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm true good point, I just based it off the original stuff I did on RTDB transaction, guess we should remove storing on there as well tbh: https://github.com/invertase/react-native-firebase/blob/master/lib/modules/database/transaction.js#L24

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, may as well.
When I did the flow types for auth and firestore, I cleaned up a lot of this sort of stuff, but haven't got to database yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove on both, ta

}

// reject the final promise and remove from native
if (updateFailed) {
Copy link
Contributor

@chrisbianca chrisbianca Feb 13, 2018

Choose a reason for hiding this comment

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

At the moment, this only exits if the promise throws an exception, not if the update function isn't returning a promise. Is this correct?

Copy link
Contributor Author

@Salakar Salakar Feb 13, 2018

Choose a reason for hiding this comment

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

Exits when the update function throws an error (e.g. bad code) or it Promise rejects. Added this as a boolean flag instead of if (finalError) { } as it's possible to Promise.reject() with no value/exception which would fall through and not exit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, was just checking I could only see the boolean being set to true in the try/catch

@Salakar Salakar changed the title [WIP] Firestore Transactions Firestore Transactions Mar 5, 2018
@Salakar Salakar merged commit 6f0fd97 into master Mar 5, 2018
@Salakar Salakar deleted the firestore-transactions branch March 5, 2018 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants