Skip to content

Commit

Permalink
Avoid sync "operation" when talking about checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Feb 21, 2025
1 parent 8ac9f45 commit 4ebad73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 7 additions & 6 deletions packages/powersync_core/lib/src/database/powersync_db_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ mixin PowerSyncDatabaseMixin implements SqliteConnection {
}
}

/// Returns a [Future] which will resolve once a synchronization operation has
/// completed.
/// Returns a [Future] which will resolve once at least one full sync cycle
/// has completed (meaninng that the first consistent checkpoint has been
/// reached across all buckets).
///
/// When [priority] is null (the default), this method waits for a full sync
/// operation to complete. When set to a [BucketPriority] however, it also
/// completes once a partial sync operation containing that priority has
/// completed.
/// When [priority] is null (the default), this method waits for the first
/// full sync checkpoint to complete. When set to a [BucketPriority] however,
/// it completes once all buckets within that priority (as well as those in
/// higher priorities) have been synchronized at least once.
Future<void> waitForFirstSync({BucketPriority? priority}) async {
bool matches(SyncStatus status) {
if (priority == null) {
Expand Down
11 changes: 7 additions & 4 deletions packages/powersync_core/lib/src/sync_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@ final class SyncStatus {
return downloadError ?? uploadError;
}

/// Returns [lastSyncedAt] and [hasSynced] information for a partial sync
/// operation, or `null` if the status for that priority is unknown.
/// Returns information for [lastSyncedAt] and [hasSynced] information at a
/// partial sync priority, or `null` if the status for that priority is
/// unknown.
///
/// The information returned may be more generic than requested. For instance,
/// a completed sync operation (as expressed by [lastSyncedAt]) also
/// guarantees that every bucket priority was synchronized before that.
/// a fully-completed sync cycle (as expressed by [lastSyncedAt]) necessarily
/// includes all buckets across all priorities. So, if no further partial
/// checkpoints have been received since that complete sync,
/// [statusForPriority] may return information for that complete sync.
/// Similarly, requesting the sync status for priority `1` may return
/// information extracted from the lower priority `2` since each partial sync
/// in priority `2` necessarily includes a consistent view over data in
Expand Down

0 comments on commit 4ebad73

Please sign in to comment.