Skip to content

Commit

Permalink
Update comments to address fetchQueryRejectFns's change to a Map
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/apollo-client/src/core/QueryManager.ts
  • Loading branch information
cheapsteak committed Feb 4, 2019
1 parent 00487c4 commit 8942220
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/apollo-client/src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ export class QueryManager<TStore> {
// subscriptions as well
private queries: Map<string, QueryInfo> = new Map();

// A set of Promise reject functions for fetchQuery promises that have not
// A map of Promise reject functions for fetchQuery promises that have not
// yet been resolved, used to keep track of in-flight queries so that we can
// reject them in case a destabilizing event occurs (e.g. Apollo store reset).
// The key is in the format of `query:${queryId}` or `fetchRequest:${queryId}`,
// depending on where the promise's rejection function was created from.
private fetchQueryRejectFns = new Map<string, Function>();

// A map going from the name of a query to an observer issued for it by watchQuery. This is
Expand Down Expand Up @@ -963,6 +965,10 @@ export class QueryManager<TStore> {
public removeQuery(queryId: string) {
const { subscriptions } = this.getQuery(queryId);
// teardown all links
// Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises
// that each add their reject functions to fetchQueryRejectFns.
// A query created with `QueryManager.query()` could trigger a `QueryManager.fetchRequest`.
// The same queryId could have two rejection fns for two promises
this.fetchQueryRejectFns.delete(`query:${queryId}`);
this.fetchQueryRejectFns.delete(`fetchRequest:${queryId}`);
subscriptions.forEach(x => x.unsubscribe());
Expand Down

0 comments on commit 8942220

Please sign in to comment.