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

Commit 3570f40

Browse files
committed
jonathan feedback
1 parent bfc5d1b commit 3570f40

File tree

5 files changed

+26
-33
lines changed

5 files changed

+26
-33
lines changed

CodePush.ios.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function checkForUpdate() {
126126
* releases, and displaying a standard confirmation UI to the end-user
127127
* when an update is available.
128128
*/
129-
function sync(options = {}, onSyncStatusChange, onDownloadProgress) {
129+
function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
130130
var syncOptions = {
131131

132132
ignoreFailedUpdates: true,
@@ -137,55 +137,55 @@ function sync(options = {}, onSyncStatusChange, onDownloadProgress) {
137137
...options
138138
};
139139

140-
onSyncStatusChange = typeof onSyncStatusChange == "function"
141-
? onSyncStatusChange
140+
syncStatusChangeCallback = typeof syncStatusChangeCallback == "function"
141+
? syncStatusChangeCallback
142142
: function(syncStatus) {
143143
switch(syncStatus) {
144144
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
145-
console.log("Checking for update.");
145+
console.log("[CodePush] Checking for update.");
146146
break;
147147
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
148-
console.log("Downloading package.");
148+
console.log("[CodePush] Downloading package.");
149149
break;
150150
case CodePush.SyncStatus.AWAITING_USER_ACTION:
151-
console.log("Awaiting user action.");
151+
console.log("[CodePush] Awaiting user action.");
152152
break;
153153
case CodePush.SyncStatus.INSTALLING_UPDATE:
154-
console.log("Installing update.");
154+
console.log("[CodePush] Installing update.");
155155
break;
156156
case CodePush.SyncStatus.IDLE:
157-
console.log("Sync is idle.");
157+
console.log("[CodePush] Sync is idle.");
158158
break;
159159
}
160160
};
161161

162-
onDownloadProgress = typeof onDownloadProgress == "function"
163-
? onDownloadProgress
162+
downloadProgressCallback = typeof downloadProgressCallback == "function"
163+
? downloadProgressCallback
164164
: function(downloadProgress) {
165-
console.log(`Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
165+
console.log(`[CodePush] Expecting ${downloadProgress.totalBytes} bytes, received ${downloadProgress.receivedBytes} bytes.`);
166166
};
167167

168168
return new Promise((resolve, reject) => {
169-
onSyncStatusChange(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
169+
syncStatusChangeCallback(CodePush.SyncStatus.CHECKING_FOR_UPDATE);
170170
checkForUpdate()
171171
.then((remotePackage) => {
172172
var doDownloadAndInstall = () => {
173-
onSyncStatusChange(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
174-
remotePackage.download(onDownloadProgress)
173+
syncStatusChangeCallback(CodePush.SyncStatus.DOWNLOADING_PACKAGE);
174+
remotePackage.download(downloadProgressCallback)
175175
.then((localPackage) => {
176-
onSyncStatusChange(CodePush.SyncStatus.INSTALLING_UPDATE);
176+
syncStatusChangeCallback(CodePush.SyncStatus.INSTALLING_UPDATE);
177177
return localPackage.install(syncOptions.rollbackTimeout, syncOptions.installMode)
178178
})
179179
.then(() => {
180-
onSyncStatusChange(CodePush.SyncStatus.IDLE);
180+
syncStatusChangeCallback(CodePush.SyncStatus.IDLE);
181181
resolve(CodePush.SyncResult.UPDATE_INSTALLED)
182182
})
183183
.catch(reject)
184184
.done();
185185
}
186186

187187
if (!remotePackage || (remotePackage.failedInstall && syncOptions.ignoreFailedUpdates)) {
188-
onSyncStatusChange(CodePush.SyncStatus.IDLE);
188+
syncStatusChangeCallback(CodePush.SyncStatus.IDLE);
189189
resolve(CodePush.SyncResult.UP_TO_DATE);
190190
}
191191
else if (syncOptions.updateDialog) {
@@ -222,7 +222,7 @@ function sync(options = {}, onSyncStatusChange, onDownloadProgress) {
222222
message += `${syncOptions.updateDialog.descriptionPrefix} ${remotePackage.description}`;
223223
}
224224

225-
onSyncStatusChange(CodePush.SyncStatus.AWAITING_USER_ACTION);
225+
syncStatusChangeCallback(CodePush.SyncStatus.AWAITING_USER_ACTION);
226226
AlertIOS.alert(syncOptions.updateTitle, message, dialogButtons);
227227
} else {
228228
doDownloadAndInstall();

Examples/CodePushDemoApp/CodePushDemoAppTests/InstallUpdateTests/DownloadAndInstallUpdateTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var DownloadAndInstallUpdateTest = React.createClass({
3939
runTest() {
4040
var update = require("./TestPackage");
4141
NativeBridge.downloadUpdate(update).done((downloadedPackage) => {
42-
NativeBridge.installUpdate(downloadedPackage, /*rollbackTimeout*/ 1000, /*restartImmediately*/ true);
42+
NativeBridge.installUpdate(downloadedPackage, /*rollbackTimeout*/ 1000, CodePushSdk.InstallMode.IMMEDIATE);
4343
});
4444
},
4545

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@ Contains details about an update package that has been downloaded locally or alr
263263
- __isFirstRun__: Flag indicating whether this is the first time the package has been run after being installed. (Boolean) This is useful for determining whether you would like to show a "What's New?" UI to the end-user after installing an update.
264264

265265
##### Methods
266-
- __install(rollbackTimeout: Number = 0, installMode: CodePush.InstallMode = CodePush.InstallMode.UPDATE_ON_RESTART): Promise<void>__: Installs this package to the application by unzipping its contents (e.g. the JS bundle) and saving it to the location on disk where the runtime expects to find the latest version of the app. If the `restartImmediately` parameter is set to `false`, the install will complete, but it won't take effect until the next time that the app is restarted. Otherwise, the app will be immediately restarted after performing the install, so that the end-user sees the changes.
266+
- __install(rollbackTimeout: Number = 0, installMode: CodePush.InstallMode = CodePush.InstallMode.UPDATE_ON_RESTART): Promise<void>__: Installs this package to the application by unzipping its contents (e.g. the JS bundle) and saving it to the location on disk where the runtime expects to find the latest version of the app. If the `InstallMode` parameter is set to `UPDATE_ON_RESTART`, the install will complete, but it won't take effect until the next time that the app is restarted. If it is `UPDATE_ON_RESUME`, it will take effect when the app is next resumed after going into the background. If the parameter is set to `IMMEDIATE`, it will immediately restart after performing the install, so that the end-user sees the changes.
267267
<br /><br />
268268
If a value greater than zero is provided to the `rollbackTimeout` parameter, the application will wait for the `notifyApplicationReady` method to be called for the given number of milliseconds.
269269
<br /><br />
270-
Note: The "rollback timer" doesn't start until the update has actually become active. If you pass a truthy value to the `restartImmediately` parameter, then the rollback timer will also start immediately. However, if you pass a falsey value, then the rollback timer will start the next time the app starts, not at the point that you called `install`.
270+
Note: The "rollback timer" doesn't start until the update has actually become active. If the `installMode` is `IMMEDIATE`, then the rollback timer will also start immediately. However, if the `installMode` is `UPDATE_ON_RESTART` or `UPDATE_ON_RESUME`, then the rollback timer will start the next time the app starts or resumes, not at the point that you called `install`.
271271

272272
#### RemotePackage
273273

@@ -280,7 +280,7 @@ The `RemotePackage` inherits all of the same properties as the `LocalPackage`, b
280280
- __downloadUrl__: The URL at which the package is available for download. (String). This property is only needed for advanced usage, since the `download` method will automatically handle the acquisition of updates for you.
281281

282282
##### Methods
283-
- __download(progressHandler?: Function): Promise<LocalPackage>__: Downloads the package update from the CodePush service. If a `progressHandler` is specified, it will be called periodically with a `DownloadProgress` object (`{ totalBytes: Number, receivedBytes: Number }`) that reports the progress of the download until the download completes. Returns a Promise that resolves with the `LocalPackage`.
283+
- __download(downloadProgressCallback?: Function): Promise<LocalPackage>__: Downloads the package update from the CodePush service. If a `downloadProgressCallback` is specified, it will be called periodically with a `DownloadProgress` object (`{ totalBytes: Number, receivedBytes: Number }`) that reports the progress of the download until the download completes. Returns a Promise that resolves with the `LocalPackage`.
284284

285285
---
286286

jsconfig.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

package-mixins.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ module.exports = (NativeCodePush) => {
66
abortDownload: function abortDownload() {
77
return NativeCodePush.abortDownload(this);
88
},
9-
download: function download(progressHandler) {
9+
download: function download(downloadProgressCallback) {
1010
if (!this.downloadUrl) {
1111
return Promise.reject(new Error("Cannot download an update without a download url"));
1212
}
1313

1414
var downloadProgressSubscription;
15-
if (progressHandler) {
15+
if (downloadProgressCallback) {
1616
// Use event subscription to obtain download progress.
1717
downloadProgressSubscription = NativeAppEventEmitter.addListener(
1818
"CodePushDownloadProgress",
19-
progressHandler
19+
downloadProgressCallback
2020
);
2121
}
2222

@@ -36,7 +36,7 @@ module.exports = (NativeCodePush) => {
3636
};
3737

3838
var local = {
39-
install: function install(rollbackTimeout = 0, installMode = NativeCodePush.codePushInstallModeImmediate) {
39+
install: function install(rollbackTimeout = 0, installMode = NativeCodePush.codePushInstallModeOnNextRestart) {
4040
return NativeCodePush.installUpdate(this, rollbackTimeout, installMode);
4141
}
4242
};

0 commit comments

Comments
 (0)