Explorar el Código

list: disconnect infinite-scroll observer to prevent memory leak

Benjamin Tissoires hace 6 años
padre
commit
e2d0faa539
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6 2
      client/components/lists/listBody.js

+ 6 - 2
client/components/lists/listBody.js

@@ -629,17 +629,21 @@ BlazeComponent.extendComponent({
         threshold: 0.25,
         threshold: 0.25,
       };
       };
 
 
-      const observer = new IntersectionObserver((entries) => {
+      this.observer = new IntersectionObserver((entries) => {
         entries.forEach((entry) => {
         entries.forEach((entry) => {
           this.spinnerShown = entry.isIntersecting;
           this.spinnerShown = entry.isIntersecting;
           this.updateList();
           this.updateList();
         });
         });
       }, options);
       }, options);
 
 
-      observer.observe(spinner);
+      this.observer.observe(spinner);
     }
     }
   },
   },
 
 
+  onDestroyed() {
+    this.observer.disconnect();
+  },
+
   updateList() {
   updateList() {
     if (this.spinnerShown) {
     if (this.spinnerShown) {
       this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
       this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);