Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bucket priorities #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Demo/PowerSyncExample/Components/ListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ struct ListView: View {
@State private var error: Error?
@State private var newList: NewListContent?
@State private var editing: Bool = false
@State private var didSync: Bool = false

var body: some View {
if !didSync {
Text("Busy with sync!").task {
do {
try await system.db.waitForFirstSync(priority: 1)
didSync = true;
} catch {}
}
}

List {
if let error {
ErrorText(error)
Expand Down
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/powersync-ja/powersync-kotlin.git",
"state" : {
"revision" : "203db74889df8a20e3c6ac38aede6b0186d2e3b5",
"version" : "1.0.0-BETA23.0"
"revision" : "0541a4744088ea24084c47c158ab116db35f9345",
"version" : "1.0.0-BETA26.0"
}
},
{
"identity" : "powersync-sqlite-core-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/powersync-ja/powersync-sqlite-core-swift.git",
"state" : {
"revision" : "5de629f7ddc649a1e89c64fde6113fe113fe14de",
"version" : "0.3.9"
"revision" : "fb313c473b17457d79bf3847905f5a288901d493",
"version" : "0.3.11"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ let package = Package(
targets: ["PowerSync"]),
],
dependencies: [
.package(url: "https://github.com/powersync-ja/powersync-kotlin.git", exact: "1.0.0-BETA23.0"),
.package(url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "0.3.9"..<"0.4.0")
.package(url: "https://github.com/powersync-ja/powersync-kotlin.git", exact: "1.0.0-BETA26.0"),
.package(url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git", "0.3.11"..<"0.4.0")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
4 changes: 4 additions & 0 deletions Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol {
func waitForFirstSync() async throws {
try await kotlinDatabase.waitForFirstSync()
}

func waitForFirstSync(priority: Int32) async throws {
try await kotlinDatabase.waitForFirstSync(priority: priority)
}

func connect(
connector: PowerSyncBackendConnector,
Expand Down
3 changes: 3 additions & 0 deletions Sources/PowerSync/PowerSyncDatabaseProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public protocol PowerSyncDatabaseProtocol: Queries {

/// Wait for the first sync to occur
func waitForFirstSync() async throws

/// Wait for the first (possibly partial) sync to occur that contains all buckets in the given priority.
func waitForFirstSync(priority: Int32) async throws

/// Connect to the PowerSync service, and keep the databases in sync.
///
Expand Down