@@ -28,21 +28,27 @@ export interface ProgressWithOperations {
2828 * The total amount of operations to download for the current sync iteration
2929 * to complete.
3030 */
31- total : number ;
31+ totalOperations : number ;
3232 /**
3333 * The amount of operations that have already been downloaded.
3434 */
35- completed : number ;
35+ downloadedOperations : number ;
3636
3737 /**
38- * Relative progress, as {@link completed} of {@link total}. This will be a number
39- * between `0.0` and `1.0`.
38+ * Relative progress, as {@link downloadedOperations} of {@link totalOperations}.
39+ *
40+ * This will be a number between `0.0` and `1.0`.
4041 */
41- fraction : number ;
42+ downloadedFraction : number ;
4243}
4344
4445/**
4546 * Provides realtime progress on how PowerSync is downloading rows.
47+ *
48+ * The progress until the next complete sync is available through the fields on {@link ProgressWithOperations},
49+ * which this class implements.
50+ * Additionally, the {@link SyncProgress.untilPriority} method can be used to otbain progress towards
51+ * a specific priority (instead of the progress for the entire download).
4652 *
4753 * The reported progress always reflects the status towards th end of a sync iteration (after
4854 * which a consistent snapshot of all buckets is available locally).
@@ -56,17 +62,18 @@ export interface ProgressWithOperations {
5662 * Also note that data is downloaded in bulk, which means that individual counters are unlikely
5763 * to be updated one-by-one.
5864 */
59- export class SyncProgress {
60- constructor ( protected internal : InternalProgressInformation ) { }
65+ export class SyncProgress implements ProgressWithOperations {
6166
62- /**
63- * Returns donwload progress towards a complete checkpoint being received.
64- *
65- * The returned {@link ProgressWithOperations} tracks the target amount of operations that need
66- * to be downloaded in total and how many of them have already been received.
67- */
68- get untilCompletion ( ) : ProgressWithOperations {
69- return this . untilPriority ( FULL_SYNC_PRIORITY ) ;
67+ totalOperations : number ;
68+ downloadedOperations : number ;
69+ downloadedFraction : number ;
70+
71+ constructor ( protected internal : InternalProgressInformation ) {
72+ const untilCompletion = this . untilPriority ( FULL_SYNC_PRIORITY ) ;
73+
74+ this . totalOperations = untilCompletion . totalOperations ;
75+ this . downloadedOperations = untilCompletion . downloadedOperations ;
76+ this . downloadedFraction = untilCompletion . downloadedFraction ;
7077 }
7178
7279 /**
@@ -89,9 +96,9 @@ export class SyncProgress {
8996
9097 let progress = total == 0 ? 0.0 : downloaded / total ;
9198 return {
92- total,
93- completed : downloaded ,
94- fraction : progress
99+ totalOperations : total ,
100+ downloadedOperations : downloaded ,
101+ downloadedFraction : progress
95102 } ;
96103 }
97104}
0 commit comments