From 1d04a02fe2696fc7f88c605e1103f4e6196cfe9e Mon Sep 17 00:00:00 2001 From: Kevin Cooper Date: Tue, 6 Sep 2016 14:17:58 -0400 Subject: [PATCH] Add callbacks for statusDidChange and downloadDidProgress See https://github.com/Microsoft/react-native-code-push#codepush --- README.md | 11 ++++++++++- index.js | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 11712e0..6dd9082 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,13 @@ yield spawn(codePushSaga, { yield spawn(codePushSaga, { syncActionName: "NAVIGATE_HOME" }); -``` \ No newline at end of file + +// Invoke a callback every time the sync status changes +// or show a status bar as the download progresses. +// You can find a list of status types at +// https://github.com/Microsoft/react-native-code-push#syncstatus. +yield spawn(codePushSaga, { + statusDidChangeCallback: this.onSyncStatusChange, + downloadDidProgressCallback: this.onSyncDownloadProgress, +}); +``` diff --git a/index.js b/index.js index 2b31869..9103581 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ export default function* codePushSaga(options = {}) { // off the "event loop". if (options.syncOnStart) { try { - yield call(sync, options.syncOptions); + yield call(sync, options.syncOptions, options.statusDidChangeCallback, options.downloadDidProgressCallback); } catch (e) { console.log(e); } @@ -107,7 +107,7 @@ export default function* codePushSaga(options = {}) { // to watch for any of the requested sync points. while (yield race(syncEvents)) { try { - yield call(sync, options.syncOptions); + yield call(sync, options.syncOptions, options.statusDidChangeCallback, options.downloadDidProgressCallback); } catch (e) { console.log(e); }