Skip to content

Commit 2fad7ca

Browse files
committed
Add helper for Swift SDK
1 parent b67a485 commit 2fad7ca

File tree

1 file changed

+14
-0
lines changed
  • PowerSyncKotlin/src/appleMain/kotlin/com/powersync

1 file changed

+14
-0
lines changed

PowerSyncKotlin/src/appleMain/kotlin/com/powersync/SDK.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
package com.powersync
44

5+
import com.powersync.sync.ConnectionMethod
6+
57
/**
68
* Helper class designed to bridge SKIEE methods and allow them to throw
79
* `PowerSyncException`. This is necessary because these exceptions cannot
@@ -13,3 +15,15 @@ package com.powersync
1315
*/
1416
@Throws(PowerSyncException::class)
1517
public fun throwPowerSyncException(exception: PowerSyncException): Unit = throw exception
18+
19+
/**
20+
* Creates a [ConnectionMethod] from a simple boolean, because creating the actual instance with
21+
* the default constructor is not possible from Swift due to an optional argument with an internal
22+
* default value.
23+
*/
24+
@OptIn(ExperimentalPowerSyncAPI::class)
25+
public fun createConnectionMethod(webSocket: Boolean): ConnectionMethod = if (webSocket) {
26+
ConnectionMethod.WebSocket()
27+
} else {
28+
ConnectionMethod.Http
29+
}

0 commit comments

Comments
 (0)