5
5
/// relative progress.
6
6
///
7
7
/// To obtain a ``ProgressWithOperations`` instance, either use ``SyncStatusData/downloadProgress``
8
- /// for global progress or ``SyncDownloadProgress/untilPriority``.
8
+ /// for global progress or ``SyncDownloadProgress/untilPriority(priority:) ``.
9
9
public protocol ProgressWithOperations {
10
10
/// How many operations need to be downloaded in total for the current download
11
11
/// to complete.
@@ -16,6 +16,12 @@ public protocol ProgressWithOperations {
16
16
}
17
17
18
18
public 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.
19
25
var fraction : Float {
20
26
if ( self . totalOperations == 0 ) {
21
27
return 0.0
@@ -28,10 +34,10 @@ public extension ProgressWithOperations {
28
34
/// Provides realtime progress on how PowerSync is downloading rows.
29
35
///
30
36
/// 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.
33
39
/// 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:) ``.
35
41
///
36
42
/// The reported progress always reflects the status towards the end of a sync iteration (after
37
43
/// which a consistent snapshot of all buckets is available locally).
@@ -45,5 +51,10 @@ public extension ProgressWithOperations {
45
51
/// Also note that data is downloaded in bulk, which means that individual counters are unlikely
46
52
/// to be updated one-by-one.
47
53
public 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.
48
59
func untilPriority( priority: BucketPriority ) -> ProgressWithOperations
49
60
}
0 commit comments