-
Notifications
You must be signed in to change notification settings - Fork 157
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
Database transactions #199
base: master
Are you sure you want to change the base?
Conversation
if (error == null && snapshot != null) { | ||
deferred.complete(Result.success(DataSnapshot(snapshot))) | ||
} else { | ||
deferred.complete(Result.failure(Throwable(error?.message))) |
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.
we've got a database specific exception class you can throw here
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.
I dont think you need to use the Result type and use https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-completable-deferred/complete-exceptionally.html instead of throwing
…e-kotlin-sdk into database-transactions
…e-kotlin-sdk into database-transactions
override fun doTransaction(currentData: MutableData) = | ||
Transaction.success(transactionUpdate(decode(strategy, currentData)) as MutableData) |
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.
override fun doTransaction(currentData: MutableData) = | |
Transaction.success(transactionUpdate(decode(strategy, currentData)) as MutableData) | |
override fun doTransaction(currentData: MutableData): Transaction.Result { | |
currentData.value = currentData.value?.let { | |
transactionUpdate(decode(strategy, it)) | |
} | |
return Transaction.success(currentData) | |
} |
I'm suggesting this change because I think transactions are not working.
We need to work with currentData.value
, not with currentData
itself.
Also we need to tolerate null
value as described in the Firebase documentation.
I'm happy to help to update and merge this PR but I'm not sure I'll be able to do the same in js and iOS.
…base-transactions # Conflicts: # firebase-database/build.gradle.kts
|
|
I wouldnt freeze it, you should be able to enable the new memory model and disable freezing. https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md
Freezing will be deprecated in future version of Kotlin |
No description provided.