Skip to content

Commit 5538a2c

Browse files
committed
restore removeQuery for easier merging
1 parent 4bc564d commit 5538a2c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/core/QueryManager.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,24 @@ export class QueryManager {
11221122
return makeObservable(variables);
11231123
}
11241124

1125+
public removeQuery(queryId: string) {
1126+
// teardown all links
1127+
// Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises
1128+
// that each add their reject functions to fetchCancelFns.
1129+
// A query created with `QueryManager.query()` could trigger a `QueryManager.fetchRequest`.
1130+
// The same queryId could have two rejection fns for two promises
1131+
this.fetchCancelFns.delete(queryId);
1132+
if (this.queries.has(queryId)) {
1133+
const oq = this.queries.get(queryId)!.observableQuery;
1134+
if (oq) {
1135+
oq["resetNotifications"]();
1136+
oq["unsubscribeFromCache"]?.();
1137+
oq.stopPolling();
1138+
}
1139+
this.queries.delete(queryId);
1140+
}
1141+
}
1142+
11251143
public broadcastQueries() {
11261144
if (this.onBroadcast) this.onBroadcast();
11271145
this.obsQueries.forEach((observableQuery) => observableQuery.notify());

0 commit comments

Comments
 (0)