GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.17k stars 155 forks source link

[firebase-database] Add more customization to "doTransaction" callback #405

Open Tosunyan opened 1 year ago

Tosunyan commented 1 year ago

Currently, the "doTransaction" callback provides limited customization, which makes it difficult for users like me to implement certain functionalities.

Here is the code snippet from the library:

override fun doTransaction(currentData: MutableData): Transaction.Result {
    currentData.value = currentData.value?.let {
        transactionUpdate(decode(strategy, it))
    }
    return Transaction.success(currentData)
}

And the implementation I currently have

override fun doTransaction(mutableData: MutableData): Transaction.Result {
    if (mutableData.value == null) {
        mutableData.value = actionMap
        return Transaction.success(mutableData)
    }

    return Transaction.abort()
}