File tree Expand file tree Collapse file tree 3 files changed +193
-216
lines changed Expand file tree Collapse file tree 3 files changed +193
-216
lines changed Original file line number Diff line number Diff line change @@ -239,10 +239,5 @@ export class DeduplicatedLoadSubset {
239239 * would reflect the mutated values rather than what was actually loaded.
240240 */
241241export function cloneOptions ( options : LoadSubsetOptions ) : LoadSubsetOptions {
242- return {
243- where : options . where ,
244- orderBy : options . orderBy ,
245- limit : options . limit ,
246- // Note: We don't clone subscription as it's not part of predicate matching
247- }
242+ return { ...options }
248243}
Original file line number Diff line number Diff line change @@ -562,6 +562,13 @@ export function queryCollectionOptions(
562562 subscribeToQuery ( localObserver , hashedQueryKey )
563563 }
564564
565+ // Tell tanstack query to GC the query when the subscription is unsubscribed
566+ // The subscription is unsubscribed when the live query is GCed.
567+ const subscription = opts . subscription
568+ subscription ?. once ( `unsubscribed` , ( ) => {
569+ queryClient . removeQueries ( { queryKey : key , exact : true } )
570+ } )
571+
565572 return readyPromise
566573 }
567574
@@ -821,10 +828,6 @@ export function queryCollectionOptions(
821828 ? undefined
822829 : new DeduplicatedLoadSubset ( createQueryFromOpts , createLocalQuery )
823830
824- // TODO: run the tests, probably some will fail bc different requests are made now
825- // so fix the test expectations
826- // then also add all the new dedup tests that Sam also added to the Electric collection
827-
828831 return {
829832 loadSubset : loadSubsetDedupe ?. loadSubset ,
830833 cleanup,
You can’t perform that action at this time.
0 commit comments