55/// relative progress.
66///
77/// To obtain a ``ProgressWithOperations`` instance, either use ``SyncStatusData/downloadProgress``
8- /// for global progress or ``SyncDownloadProgress/untilPriority``.
8+ /// for global progress or ``SyncDownloadProgress/untilPriority(priority:) ``.
99public protocol ProgressWithOperations {
1010 /// How many operations need to be downloaded in total for the current download
1111 /// to complete.
@@ -16,6 +16,12 @@ public protocol ProgressWithOperations {
1616}
1717
1818public extension ProgressWithOperations {
19+ /// The relative amount of ``totalOperations`` to items in ``downloadedOperations``, as a
20+ /// number between `0.0` and `1.0` (inclusive).
21+ ///
22+ /// When this number reaches `1.0`, all changes have been received from the sync service.
23+ /// Actually applying these changes happens before the ``SyncStatusData/downloadProgress``
24+ /// field is cleared though, so progress can stay at `1.0` for a short while before completing.
1925 var fraction : Float {
2026 if ( self . totalOperations == 0 ) {
2127 return 0.0
@@ -28,10 +34,10 @@ public extension ProgressWithOperations {
2834/// Provides realtime progress on how PowerSync is downloading rows.
2935///
3036/// This type reports progress by extending ``ProgressWithOperations``, meaning that the
31- /// ``totalOperations``, ``downloadedOperations`` and ``fraction`` properties are available
32- /// on this instance.
37+ /// ``ProgressWithOperations/ totalOperations``, ``ProgressWithOperations/ downloadedOperations``
38+ /// and ``ProgressWithOperations/fraction`` properties are available on this instance.
3339/// Additionally, it's possible to obtain progress towards a specific priority only (instead
34- /// of tracking progress for the entire download) by using ``untilPriority``.
40+ /// of tracking progress for the entire download) by using ``untilPriority(priority:) ``.
3541///
3642/// The reported progress always reflects the status towards the end of a sync iteration (after
3743/// which a consistent snapshot of all buckets is available locally).
@@ -45,5 +51,10 @@ public extension ProgressWithOperations {
4551/// Also note that data is downloaded in bulk, which means that individual counters are unlikely
4652/// to be updated one-by-one.
4753public protocol SyncDownloadProgress : ProgressWithOperations {
54+ /// Returns download progress towardss all data up until the specified `priority`
55+ /// being received.
56+ ///
57+ /// The returned ``ProgressWithOperations`` instance tracks the target amount of operations that
58+ /// need to be downloaded in total and how many of them have already been received.
4859 func untilPriority( priority: BucketPriority ) -> ProgressWithOperations
4960}
0 commit comments