mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-15 10:27:59 +08:00
34 lines
614 B
JavaScript
34 lines
614 B
JavaScript
let NativeCodePush = require("react-native").NativeModules.CodePush;
|
|
|
|
const RestartManager = (() => {
|
|
let _allowed = true;
|
|
|
|
function restartApp(onlyIfUpdateIsPending = false) {
|
|
if (_allowed) {
|
|
NativeCodePush.restartApp(onlyIfUpdateIsPending);
|
|
}
|
|
}
|
|
|
|
function allow() {
|
|
_allowed = true;
|
|
restartApp(true);
|
|
}
|
|
|
|
function allowed() {
|
|
return _allowed
|
|
}
|
|
|
|
function disallow() {
|
|
_allowed = false;
|
|
}
|
|
|
|
return {
|
|
allow,
|
|
disallow,
|
|
allowed,
|
|
restartApp,
|
|
};
|
|
})();
|
|
|
|
module.exports = RestartManager;
|