Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 08a1ad5

Browse files
committed
Add download progress sample
1 parent 55ac6e9 commit 08a1ad5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -617,24 +617,31 @@ In addition to the options, the `sync` method also accepts two optional function
617617
* __syncStatusChangedCallback__ *((syncStatus: Number) => void)* - Called when the sync process moves from one stage to another in the overall update process. The method is called with a status code which represents the current state, and can be any of the [`SyncStatus`](#syncstatus) values.
618618
619619
* __downloadProgressCallback__ *((progress: DownloadProgress) => void)* - Called periodically when an available update is being downloaded from the CodePush server. The method is called with a `DownloadProgress` object, which contains the following two properties:
620-
* __totalBytes__ *(Number)* - The total number of bytes expected to be received for this update package
621-
* __receivedBytes__ *(Number)* - The number of bytes downloaded thus far.
620+
621+
* __totalBytes__ *(Number)* - The total number of bytes expected to be received for this update (i.e. the size of the set of files which changed from the previous release).
622+
623+
* __receivedBytes__ *(Number)* - The number of bytes downloaded thus far, which can be used to track download progress.
622624
623625
Example Usage:
624626
625627
```javascript
626628
// Prompt the user when an update is available
627629
// and then display a "downloading" modal
628-
codePush.sync({ updateDialog: true }, (status) => {
629-
switch (status) {
630-
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
631-
// Show "downloading" modal
632-
break;
633-
case codePush.SyncStatus.INSTALLING_UPDATE:
634-
// Hide "downloading" modal
635-
break;
636-
}
637-
});
630+
codePush.sync({ updateDialog: true },
631+
(status) => {
632+
switch (status) {
633+
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
634+
// Show "downloading" modal
635+
break;
636+
case codePush.SyncStatus.INSTALLING_UPDATE:
637+
// Hide "downloading" modal
638+
break;
639+
}
640+
},
641+
(totalBytes, receivedBytes) => {
642+
/* Update download modal progress */
643+
}
644+
);
638645
```
639646
640647
This method returns a `Promise` which is resolved to a `SyncStatus` code that indicates why the `sync` call succeeded. This code can be one of the following `SyncStatus` values:

0 commit comments

Comments
 (0)