1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-11-01 22:03:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

feat: add afterDownloadUpdate

This commit is contained in:
sunnylqm
2025-03-20 18:45:51 +08:00
parent 90f6b7bcb3
commit 0019e9dd95
3 changed files with 11 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.26.4", "version": "10.27.0",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index", "main": "src/index",
"scripts": { "scripts": {

View File

@@ -100,6 +100,14 @@ export const UpdateProvider = ({
return false; return false;
} }
stateListener.current && stateListener.current.remove(); stateListener.current && stateListener.current.remove();
if (
options.afterDownloadUpdate &&
(await options.afterDownloadUpdate(info)) === false
) {
log('afterDownloadUpdate returned false, skipping');
return false;
}
if (options.updateStrategy === 'silentAndNow') { if (options.updateStrategy === 'silentAndNow') {
client.switchVersion(hash); client.switchVersion(hash);
return true; return true;
@@ -134,6 +142,7 @@ export const UpdateProvider = ({
[ [
client, client,
options.updateStrategy, options.updateStrategy,
options.afterDownloadUpdate,
alertUpdate, alertUpdate,
alertError, alertError,
throwErrorIfEnabled, throwErrorIfEnabled,

View File

@@ -88,6 +88,7 @@ export interface ClientOptions {
throwError?: boolean; throwError?: boolean;
beforeCheckUpdate?: () => Promise<boolean>; beforeCheckUpdate?: () => Promise<boolean>;
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>; beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
afterDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
} }
export interface UpdateTestPayload { export interface UpdateTestPayload {