Skip to content

Commit 63d290a

Browse files
Add database runTransaction expect and js externals
1 parent bdea157 commit 63d290a

File tree

2 files changed

+7
-0
lines changed
  • firebase-common/src/jsMain/kotlin/dev/gitlive/firebase
  • firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database

2 files changed

+7
-0
lines changed

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ external object firebase {
317317
fun update(value: Any?): Promise<Unit>
318318
fun set(value: Any?): Promise<Unit>
319319
fun push(): ThenableReference
320+
fun <T> runTransaction(
321+
transactionUpdate: (currentData: T) -> T,
322+
onComplete: (error: Error?, committed: Boolean, snapshot: DataSnapshot?) -> Unit,
323+
applyLocally: Boolean?
324+
): Promise<T>
320325
}
321326

322327
open class DataSnapshot {

firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ expect class DatabaseReference : Query {
7171
suspend fun <T> setValue(strategy: SerializationStrategy<T>, value: T, encodeDefaults: Boolean = true)
7272
suspend fun updateChildren(update: Map<String, Any?>, encodeDefaults: Boolean = true)
7373
suspend fun removeValue()
74+
75+
suspend fun <T> runTransaction(strategy: KSerializer<T>, transactionUpdate: (currentData: T) -> T): DataSnapshot
7476
}
7577

7678
expect class DataSnapshot {

0 commit comments

Comments
 (0)