Skip to content

Commit 306db07

Browse files
committed
Support bucket priorities
1 parent abca0c9 commit 306db07

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

Demo/PowerSyncExample/Components/ListView.swift

Lines changed: 10 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
],
1818
dependencies: [
1919
.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")
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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)