Skip to main content

SyncProgress

Provides realtime progress on how PowerSync is downloading rows.

The progress until the next complete sync is available through the fields on ProgressWithOperations, which this class implements. Additionally, the SyncProgress.untilPriority method can be used to otbain progress towards a specific priority (instead of the progress for the entire download).

The reported progress always reflects the status towards the end of a sync iteration (after which a consistent snapshot of all buckets is available locally).

In rare cases (in particular, when a compacting operation takes place between syncs), it's possible for the returned numbers to be slightly inaccurate. For this reason, SyncProgress should be seen as an approximation of progress. The information returned is good enough to build progress bars, but not exact enough to track individual download counts.

Also note that data is downloaded in bulk, which means that individual counters are unlikely to be updated one-by-one.

Implements

Constructors

new SyncProgress()

new SyncProgress(internal): SyncProgress

Parameters

ParameterType
internalInternalProgressInformation

Returns

SyncProgress

Properties

PropertyTypeDescription
downloadedFractionnumberRelative progress, as downloadedOperations of totalOperations. This will be a number between 0.0 and 1.0 (inclusive). When this number reaches 1.0, all changes have been received from the sync service. Actually applying these changes happens before the downloadProgress field is cleared from SyncStatus, so progress can stay at 1.0 for a short while before completing.
downloadedOperationsnumberThe amount of operations that have already been downloaded.
totalOperationsnumberThe total amount of operations to download for the current sync iteration to complete.

Methods

untilPriority()

untilPriority(priority): ProgressWithOperations

Returns download progress towards all data up until the specified priority being received.

The returned ProgressWithOperations tracks the target amount of operations that need to be downloaded in total and how many of them have already been received.

Parameters

ParameterType
prioritynumber

Returns

ProgressWithOperations