[#128] generic data provider improvments
This commit is contained in:
parent
6e6a79d8e3
commit
7ba74eeafd
@ -22,7 +22,7 @@ export interface Subscribe<Data, Delta> {
|
||||
callback: UpdateCallback<Data, Delta>,
|
||||
client: ApolloClient<object>,
|
||||
variables?: OperationVariables
|
||||
): void;
|
||||
): () => void;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
@ -5,7 +5,7 @@ import type { Subscribe } from '@vegaprotocol/graphql';
|
||||
|
||||
export function useDataProvider<Data, Delta>(
|
||||
dataProvider: Subscribe<Data, Delta>,
|
||||
update: (delta: Delta) => boolean = () => false,
|
||||
update?: (delta: Delta) => boolean,
|
||||
variables?: OperationVariables
|
||||
) {
|
||||
const client = useApolloClient();
|
||||
@ -18,7 +18,7 @@ export function useDataProvider<Data, Delta>(
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user