This repository was archived by the owner on May 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
CodePush.sync() API method #22
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LGTM! |
return new Promise((resolve, reject) => { | ||
checkForUpdate() | ||
.then((remotePackage) => { | ||
if (!remotePackage || (remotePackage.failedAppy && syncOptions.ignoreFailedUpdates)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failedApply?
LGTM |
remotePackage.download() | ||
.then((localPackage) => { | ||
resolve(CodePush.SyncStatus.UPDATE_DOWNLOADED); | ||
localPackage.apply(syncOptions.rollbackTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey I don't think a failure in the apply promise is being handled here - would it be better to do:
return localPackage.apply(syncOptions.rollbackTimeout);
})
.catch(reject)
.done();
LGTM! |
lostintangent
added a commit
that referenced
this pull request
Oct 29, 2015
CodePush.sync() API method
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This provides a simplified and opinionated one-line experience to CodePush-ifying an app. The CodePush.sync() method allows automating the act of checking for an update, downloading it and then subsequently applying it, all while also supporting ignoring previously failed updates, respecting mandatory updates and displaying a standard user confirmation dialog when updates are available.
The method takes an optional options object that can be used to customize the strings used when displaying the user dialog, as well as the rollback timeout.
It returns a Promise that will be resolved with a SyncStatus code, that indicates why the sync succeeded:
0 - No update was available, so the running app is up to do
1 - The app had an optional update, but the end-user chose to ignore it
2 - The app had an optional or mandatory update and the user accepted it
If a failure occurs at any point during the sync, the returned Promise will be rejected with the error reason.
I'll update the docs in a subsequent PR, but I just wanted to get this change out since the respective Cordova change is in review.