Merge pull request #3016 from Arooba-git/fix-subscription-memory-leak

Fix subscription memory leak
This commit is contained in:
softsimon 2023-02-14 13:37:00 +07:00 committed by GitHub
commit 0e4bebb870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -0,0 +1,3 @@
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of January 25, 2022.
Signed: Arooba-git

View File

@ -1,7 +1,7 @@
import { Component, OnInit, Input, QueryList, AfterViewInit, ViewChildren } from '@angular/core';
import { Env, StateService } from '../../services/state.service';
import { Observable, merge, of } from 'rxjs';
import { tap } from 'rxjs/operators';
import { Observable, merge, of, Subject } from 'rxjs';
import { tap, takeUntil } from 'rxjs/operators';
import { ActivatedRoute } from "@angular/router";
import { faqData, restApiDocsData, wsApiDocsData } from './api-docs-data';
import { FaqTemplateDirective } from '../faq-template/faq-template.component';
@ -12,6 +12,7 @@ import { FaqTemplateDirective } from '../faq-template/faq-template.component';
styleUrls: ['./api-docs.component.scss']
})
export class ApiDocsComponent implements OnInit, AfterViewInit {
private destroy$: Subject<any> = new Subject<any>();
plainHostname = document.location.hostname;
electrsPort = 0;
hostname = document.location.hostname;
@ -82,7 +83,7 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
this.restDocs = restApiDocsData;
this.wsDocs = wsApiDocsData;
this.network$.subscribe((network) => {
this.network$.pipe(takeUntil(this.destroy$)).subscribe((network) => {
this.active = (network === 'liquid' || network === 'liquidtestnet') ? 2 : 0;
switch( network ) {
case "":
@ -102,6 +103,8 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
}
ngOnDestroy(): void {
this.destroy$.next(true);
this.destroy$.complete();
window.removeEventListener('scroll', this.onDocScroll);
}