mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-28 23:51:07 +08:00
32 lines
876 B
JavaScript
32 lines
876 B
JavaScript
var extend = require("extend");
|
|
|
|
module.exports = (NativeCodePush) => {
|
|
var remote = {
|
|
abortDownload: function abortDownload() {
|
|
return NativeCodePush.abortDownload(this);
|
|
},
|
|
download: function download() {
|
|
if (!this.downloadUrl) {
|
|
return Promise.reject(new Error("Cannot download an update without a download url"));
|
|
}
|
|
|
|
// Use the downloaded package info. Native code will save the package info
|
|
// so that the client knows what the current package version is.
|
|
return NativeCodePush.downloadUpdate(this)
|
|
.then((downloadedPackage) => {
|
|
return extend({}, downloadedPackage, local);
|
|
});
|
|
}
|
|
};
|
|
|
|
var local = {
|
|
apply: function apply(rollbackTimeout = 0) {
|
|
return NativeCodePush.applyUpdate(this, rollbackTimeout);
|
|
}
|
|
};
|
|
|
|
return {
|
|
remote: remote,
|
|
local: local
|
|
};
|
|
}; |