aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-06-06 00:09:25 -0300
committerSebastian <sebasjm@gmail.com>2022-06-06 00:09:25 -0300
commitfb6aff76d2152d95caa2ba6cb0d91cb01e0687fe (patch)
tree2dc9b0a4935f60ba7229fd81332ec4a41ad4698c /packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
parent912813fd09ee2f757e4d6d509a911159b46153a7 (diff)
downloadwallet-core-fb6aff76d2152d95caa2ba6cb0d91cb01e0687fe.tar.xz
prettier
Diffstat (limited to 'packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts')
-rw-r--r--packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
index 04a6dbb18..d13a68383 100644
--- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts
@@ -13,9 +13,7 @@
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import {
- NotificationType, TalerErrorDetail
-} from "@gnu-taler/taler-util";
+import { NotificationType, TalerErrorDetail } from "@gnu-taler/taler-util";
import { TalerError } from "@gnu-taler/taler-wallet-core";
import { useEffect, useMemo, useState } from "preact/hooks";
import * as wxApi from "../wxApi.js";
@@ -44,19 +42,23 @@ interface WithRetry {
}
export type HookResponse<T> = HookOk<T> | HookError | undefined;
-export type HookResponseWithRetry<T> = ((HookOk<T> | HookError) & WithRetry) | undefined;
+export type HookResponseWithRetry<T> =
+ | ((HookOk<T> | HookError) & WithRetry)
+ | undefined;
export function useAsyncAsHook<T>(
fn: () => Promise<T | false>,
deps?: any[],
): HookResponseWithRetry<T> {
-
const [result, setHookResponse] = useState<HookResponse<T>>(undefined);
- const args = useMemo(() => ({
- fn
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }), deps || [])
+ const args = useMemo(
+ () => ({
+ fn,
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }),
+ deps || [],
+ );
async function doAsync(): Promise<void> {
try {