1
1
import { ENV_TYPE , getUpdateManager , UpdateManager } from '@tarojs/taro' ;
2
- import { useCallback , useEffect , useRef , useState } from 'react' ;
2
+ import { useCallback , useEffect , useRef } from 'react' ;
3
3
import useEnv from '../useEnv' ;
4
4
5
- export interface Options {
6
- applyUpdate : ( ) => void ;
7
- }
8
-
9
5
export type Result = UpdateManager | { } ;
10
6
11
7
function useUpdateManager ( {
12
- applyUpdate,
13
8
onCheckForUpdate,
14
9
onUpdateReady,
15
10
onUpdateFailed,
@@ -21,15 +16,14 @@ function useUpdateManager({
21
16
if ( env === ENV_TYPE . WEAPP ) {
22
17
const updateManagerInstance = getUpdateManager ( ) ;
23
18
addEventListener ( updateManagerInstance ) ;
24
- updateManager . current = getUpdateManager ( ) ;
19
+ updateManager . current = updateManagerInstance ;
25
20
}
26
- } , [ ] ) ;
21
+ } , [ env ] ) ;
27
22
28
23
const addEventListener = useCallback ( ( updateManagerInstance ) => {
29
- updateManagerInstance . applyUpdate = applyUpdate ;
30
- updateManagerInstance . onCheckForUpdate = onCheckForUpdate ;
31
- updateManagerInstance . onUpdateReady = onUpdateReady ;
32
- updateManagerInstance . onUpdateFailed = onUpdateFailed ;
24
+ updateManagerInstance . onCheckForUpdate ( onCheckForUpdate ) ;
25
+ updateManagerInstance . onUpdateReady ( onUpdateReady ) ;
26
+ updateManagerInstance . onUpdateFailed ( onUpdateFailed ) ;
33
27
} , [ ] ) ;
34
28
35
29
return updateManager ;
0 commit comments