Skip to content

Commit

Permalink
fix issue 115
Browse files Browse the repository at this point in the history
When dispose is made it is necessary to recreate the queryFetcher and reset the loadQuery data as in the initial state.

This ensures that the next call is made as if a new loadQuery were created.
  • Loading branch information
morrys committed Sep 24, 2020
1 parent ce305c3 commit 4be49a4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/loadQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ const internalLoadQuery = <TOperationType extends OperationType = OperationType>
promise = false,
): LoadQuery<TOperationType> => {
let data: RenderProps<TOperationType> | null | Promise<any> = null;
let listener;
let listener = undefined;
let queryFetcher = new QueryFetcher<TOperationType>(true);

const queryFetcher = new QueryFetcher<TOperationType>(true);

const prev = {
let prev = {
environment: null,
gqlQuery: null,
variables: null,
Expand All @@ -22,7 +21,16 @@ const internalLoadQuery = <TOperationType extends OperationType = OperationType>

const dispose = (): void => {
queryFetcher.dispose();
listener = null;
queryFetcher = new QueryFetcher<TOperationType>(true);
listener = undefined;
data = null;
prev = {
environment: null,
gqlQuery: null,
variables: null,
options: null,
query: null,
};
};

const next = (
Expand Down

0 comments on commit 4be49a4

Please sign in to comment.