Skip to content

Commit

Permalink
v10.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Aug 24, 2024
1 parent 5659c79 commit d000c40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.11.8",
"version": "10.12.0",
"description": "react-native hot update",
"main": "src/index",
"scripts": {
Expand Down
14 changes: 14 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ export class Pushy {
console.warn('web 端不支持热更新检查');
return;
}
if (
this.options.beforeCheckUpdate &&
(await this.options.beforeCheckUpdate()) === false
) {
log('beforeCheckUpdate 返回 false, 忽略检查');
return;
}
const now = Date.now();
if (
this.lastRespJson &&
Expand Down Expand Up @@ -275,6 +282,13 @@ export class Pushy {
description,
metaInfo,
} = info;
if (
this.options.beforeDownloadUpdate &&
(await this.options.beforeDownloadUpdate(info)) === false
) {
log('beforeDownloadUpdate 返回 false, 忽略下载');
return;
}
if (!info.update || !hash) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export interface PushyOptions {
dismissErrorAfter?: number;
debug?: boolean;
throwError?: boolean;
beforeCheckUpdate?: () => Promise<boolean>;
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
}

export interface PushyTestPayload {
Expand Down

0 comments on commit d000c40

Please sign in to comment.