From 7ba74eeafdf8ba6d4e9836f84cf3ba87890b63b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20G=C5=82ownia?= Date: Mon, 28 Mar 2022 17:14:00 +0200 Subject: [PATCH] [#128] generic data provider improvments --- libs/graphql/src/data-providers/generic-data-provider.ts | 2 +- libs/react-helpers/src/hooks/use-data-provider.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/graphql/src/data-providers/generic-data-provider.ts b/libs/graphql/src/data-providers/generic-data-provider.ts index 6fdec30ae..64d93b978 100644 --- a/libs/graphql/src/data-providers/generic-data-provider.ts +++ b/libs/graphql/src/data-providers/generic-data-provider.ts @@ -22,7 +22,7 @@ export interface Subscribe { callback: UpdateCallback, client: ApolloClient, variables?: OperationVariables - ): void; + ): () => void; } // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/libs/react-helpers/src/hooks/use-data-provider.ts b/libs/react-helpers/src/hooks/use-data-provider.ts index 7d5ade70a..9cf3a99d3 100644 --- a/libs/react-helpers/src/hooks/use-data-provider.ts +++ b/libs/react-helpers/src/hooks/use-data-provider.ts @@ -5,7 +5,7 @@ import type { Subscribe } from '@vegaprotocol/graphql'; export function useDataProvider( dataProvider: Subscribe, - update: (delta: Delta) => boolean = () => false, + update?: (delta: Delta) => boolean, variables?: OperationVariables ) { const client = useApolloClient(); @@ -18,7 +18,7 @@ export function useDataProvider( setError(error); setLoading(loading); if (!error && !loading) { - if (!initialized.current || !delta || !update(delta)) { + if (!initialized.current || !delta || !update || !update(delta)) { initialized.current = true; setData(data); }