diff options
author | Sebastian <sebasjm@gmail.com> | 2022-04-25 23:07:31 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-04-26 11:48:29 -0300 |
commit | 41ab855736815d33f5fdbebc896b167c71482eee (patch) | |
tree | b1c61f37f107f8118215483c4945bc942ee45b7a /packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | |
parent | 65e6a8caa0de98632ad99cca35bf98bffe663dff (diff) | |
download | wallet-core-41ab855736815d33f5fdbebc896b167c71482eee.tar.xz |
remove old async hook
Diffstat (limited to 'packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts index d03455ff7..04a6dbb18 100644 --- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts +++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts @@ -48,50 +48,6 @@ export type HookResponseWithRetry<T> = ((HookOk<T> | HookError) & WithRetry) | u export function useAsyncAsHook<T>( fn: () => Promise<T | false>, - updateOnNotification?: Array<NotificationType>, - deps?: any[], -): HookResponse<T> { - - const args = useMemo(() => ({ - fn, updateOnNotification - // eslint-disable-next-line react-hooks/exhaustive-deps - }), deps || []) - const [result, setHookResponse] = useState<HookResponse<T>>(undefined); - - useEffect(() => { - async function doAsync(): Promise<void> { - try { - const response = await args.fn(); - if (response === false) return; - setHookResponse({ hasError: false, response }); - } catch (e) { - if (e instanceof TalerError) { - setHookResponse({ - hasError: true, - operational: true, - details: e.errorDetail, - }); - } else if (e instanceof Error) { - setHookResponse({ - hasError: true, - operational: false, - message: e.message, - }); - } - } - } - doAsync(); - if (args.updateOnNotification && args.updateOnNotification.length > 0) { - return wxApi.onUpdateNotification(args.updateOnNotification, () => { - doAsync(); - }); - } - }, [args]); - return result; -} - -export function useAsyncAsHook2<T>( - fn: () => Promise<T | false>, deps?: any[], ): HookResponseWithRetry<T> { |