Skip to content

Commit 3cb5001

Browse files
author
psubram3
committed
fix subscribable bug
1 parent 7ca57f9 commit 3cb5001

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/stores/subscribable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function gqlSubscribable<T>(
159159
// and resubscribe to the main query with those new variables
160160
const store = variable as Readable<any>;
161161
const unsubscriber = store.subscribe(storeValue => {
162-
variables = { ...variables, [name]: storeValue };
162+
variables = { ...variables, [name]: storeValue }; // NOTE: when modifying this, I made the mistake in subscribe of passing 'variables' instead of 'initialVariables'. 'variables' seems to contain exclusively values, while 'initialVariables' seems to contain possible references to stores. I think these names are a little misleading and should be refactored somewhat!
163163
resubscribe();
164164
});
165165
variableUnsubscribers.push(unsubscriber);
@@ -171,7 +171,7 @@ export function gqlSubscribable<T>(
171171
function subscribe(next: Subscriber<T>): Unsubscriber {
172172
// If we are in the browser and do not yet have a web socket client
173173
// we will create one and subscribe to variables
174-
subscribeToVariables(variables); // should not be harmful if this runs every time subscribe is called
174+
subscribeToVariables(initialVariables); // should not be harmful if this runs every time subscribe is called
175175

176176
// Subscribe within the WS to the GQL query
177177
// Note that subscribeToVariables may immediately result in a resubscription if

0 commit comments

Comments
 (0)