diff --git a/CodePush.js b/CodePush.js
index 5072db6..e3c726d 100644
--- a/CodePush.js
+++ b/CodePush.js
@@ -170,8 +170,20 @@ function setUpTestDependencies(testSdk, providedTestConfig, testNativeBridge) {
if (testNativeBridge) NativeCodePush = testNativeBridge;
}
+// This function allows sync operations to be chained on to each other so that they do not
+// interleave in the event that sync() is called multiple times.
+const sync = (() => {
+ let syncPromiseChain = Promise.resolve();
+ return (options = {}, syncStatusChangeCallback, downloadProgressCallback) => {
+ syncPromiseChain = syncPromiseChain
+ .catch(() => {})
+ .then(() => syncOperation(options, syncStatusChangeCallback, downloadProgressCallback));
+ return syncPromiseChain;
+ };
+})();
+
/*
- * The sync method provides a simple, one-line experience for
+ * The syncOperation method provides a simple, one-line experience for
* incorporating the check, download and application of an update.
*
* It simply composes the existing API methods together and adds additional
@@ -179,7 +191,7 @@ function setUpTestDependencies(testSdk, providedTestConfig, testNativeBridge) {
* releases, and displaying a standard confirmation UI to the end-user
* when an update is available.
*/
-async function sync(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
+async function syncOperation(options = {}, syncStatusChangeCallback, downloadProgressCallback) {
const syncOptions = {
deploymentKey: null,
diff --git a/CodePushPackage.m b/CodePushPackage.m
index 888c080..20ed64a 100644
--- a/CodePushPackage.m
+++ b/CodePushPackage.m
@@ -449,7 +449,7 @@ NSString * const UnzippedFolderName = @"unzipped";
}
+ (void)installPackage:(NSDictionary *)updatePackage
- error:(NSError **)error
+ error:(NSError **)error
{
NSString *packageHash = updatePackage[@"packageHash"];
NSMutableDictionary *info = [self getCurrentPackageInfo:error];
diff --git a/Examples/CodePushDemoApp/crossplatformdemo.js b/Examples/CodePushDemoApp/crossplatformdemo.js
index d941af0..642165a 100644
--- a/Examples/CodePushDemoApp/crossplatformdemo.js
+++ b/Examples/CodePushDemoApp/crossplatformdemo.js
@@ -92,16 +92,22 @@ let CodePushDemoApp = React.createClass({
render() {
let syncView, syncButton, progressView;
- if (this.state.syncMessage) {
- syncView = (
- {this.state.syncMessage}
- );
- } else {
syncButton = (
);
+
+ if (this.state.syncMessage) {
+ syncView = (
+ {this.state.syncMessage}
+ );
+ } else {
+ /*syncButton = (
+
+ );*/
}
if (this.state.progress) {