-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
…/react-native-firebase into firestore-transactions
…rebase into firestore-transactions
…rebase into firestore-transactions
@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! |
@HofmannZ Interesting! Thanks for that :) |
*/ | ||
export default class TransactionHandler { | ||
_firestore: Firestore; | ||
_transactionListener: Function; |
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.
Is there any reason to store this as we never unsubscribe from the listener?
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.
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
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, 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.
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.
Will remove on both, ta
} | ||
|
||
// reject the final promise and remove from native | ||
if (updateFailed) { |
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.
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?
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.
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.
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.
Ok, was just checking I could only see the boolean being set to true in the try/catch
…/react-native-firebase into firestore-transactions
…/react-native-firebase into firestore-transactions
…er at the start of each cycle
…estore-transactions
…w uses [transactionId stringValue])
Adds firestore transaction support for both Android & iOS