Skip to content

Commit 0019e9d

Browse files
committed
feat: add afterDownloadUpdate
1 parent 90f6b7b commit 0019e9d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.26.4",
3+
"version": "10.27.0",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/provider.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ export const UpdateProvider = ({
100100
return false;
101101
}
102102
stateListener.current && stateListener.current.remove();
103+
104+
if (
105+
options.afterDownloadUpdate &&
106+
(await options.afterDownloadUpdate(info)) === false
107+
) {
108+
log('afterDownloadUpdate returned false, skipping');
109+
return false;
110+
}
103111
if (options.updateStrategy === 'silentAndNow') {
104112
client.switchVersion(hash);
105113
return true;
@@ -134,6 +142,7 @@ export const UpdateProvider = ({
134142
[
135143
client,
136144
options.updateStrategy,
145+
options.afterDownloadUpdate,
137146
alertUpdate,
138147
alertError,
139148
throwErrorIfEnabled,

src/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export interface ClientOptions {
8888
throwError?: boolean;
8989
beforeCheckUpdate?: () => Promise<boolean>;
9090
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
91+
afterDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
9192
}
9293

9394
export interface UpdateTestPayload {

0 commit comments

Comments
 (0)