list: disconnect infinite-scroll observer to prevent memory leak

This commit is contained in:
Benjamin Tissoires 2019-03-26 16:22:55 +01:00
parent cbb6c82113
commit e2d0faa539

View file

@ -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);