Skip to content

Commit 7a32cfb

Browse files
authored
Support bucket priorities (#25)
* Support bucket priorities * Update Kotlin SDK
1 parent abca0c9 commit 7a32cfb

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

Demo/PowerSyncExample/Components/ListView.swift

+10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,18 @@ struct ListView: View {
99
@State private var error: Error?
1010
@State private var newList: NewListContent?
1111
@State private var editing: Bool = false
12+
@State private var didSync: Bool = false
1213

1314
var body: some View {
15+
if !didSync {
16+
Text("Busy with sync!").task {
17+
do {
18+
try await system.db.waitForFirstSync(priority: 1)
19+
didSync = true;
20+
} catch {}
21+
}
22+
}
23+
1424
List {
1525
if let error {
1626
ErrorText(error)

Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"kind" : "remoteSourceControl",
66
"location" : "https://github.com/powersync-ja/powersync-kotlin.git",
77
"state" : {
8-
"revision" : "203db74889df8a20e3c6ac38aede6b0186d2e3b5",
9-
"version" : "1.0.0-BETA23.0"
8+
"revision" : "0541a4744088ea24084c47c158ab116db35f9345",
9+
"version" : "1.0.0-BETA26.0"
1010
}
1111
},
1212
{
1313
"identity" : "powersync-sqlite-core-swift",
1414
"kind" : "remoteSourceControl",
1515
"location" : "https://github.com/powersync-ja/powersync-sqlite-core-swift.git",
1616
"state" : {
17-
"revision" : "5de629f7ddc649a1e89c64fde6113fe113fe14de",
18-
"version" : "0.3.9"
17+
"revision" : "fb313c473b17457d79bf3847905f5a288901d493",
18+
"version" : "0.3.11"
1919
}
2020
}
2121
],

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let package = Package(
1616
targets: ["PowerSync"]),
1717
],
1818
dependencies: [
19-
.package(url: "https://github.com/powersync-ja/powersync-kotlin.git", exact: "1.0.0-BETA23.0"),
20-
.package(url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "0.3.9"..<"0.4.0")
19+
.package(url: "https://github.com/powersync-ja/powersync-kotlin.git", exact: "1.0.0-BETA26.0"),
20+
.package(url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "0.3.11"..<"0.4.0")
2121
],
2222
targets: [
2323
// Targets are the basic building blocks of a package, defining a module or a test suite.

Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol {
2525
func waitForFirstSync() async throws {
2626
try await kotlinDatabase.waitForFirstSync()
2727
}
28+
29+
func waitForFirstSync(priority: Int32) async throws {
30+
try await kotlinDatabase.waitForFirstSync(priority: priority)
31+
}
2832

2933
func connect(
3034
connector: PowerSyncBackendConnector,

Sources/PowerSync/PowerSyncDatabaseProtocol.swift

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public protocol PowerSyncDatabaseProtocol: Queries {
1313

1414
/// Wait for the first sync to occur
1515
func waitForFirstSync() async throws
16+
17+
/// Wait for the first (possibly partial) sync to occur that contains all buckets in the given priority.
18+
func waitForFirstSync(priority: Int32) async throws
1619

1720
/// Connect to the PowerSync service, and keep the databases in sync.
1821
///

0 commit comments

Comments
 (0)