Merge pull request #3016 from Arooba-git/fix-subscription-memory-leak
Fix subscription memory leak
This commit is contained in:
commit
0e4bebb870
3
contributors/Arooba-git.txt
Normal file
3
contributors/Arooba-git.txt
Normal 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
|
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit, Input, QueryList, AfterViewInit, ViewChildren } from '@angular/core';
|
import { Component, OnInit, Input, QueryList, AfterViewInit, ViewChildren } from '@angular/core';
|
||||||
import { Env, StateService } from '../../services/state.service';
|
import { Env, StateService } from '../../services/state.service';
|
||||||
import { Observable, merge, of } from 'rxjs';
|
import { Observable, merge, of, Subject } from 'rxjs';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap, takeUntil } from 'rxjs/operators';
|
||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { faqData, restApiDocsData, wsApiDocsData } from './api-docs-data';
|
import { faqData, restApiDocsData, wsApiDocsData } from './api-docs-data';
|
||||||
import { FaqTemplateDirective } from '../faq-template/faq-template.component';
|
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']
|
styleUrls: ['./api-docs.component.scss']
|
||||||
})
|
})
|
||||||
export class ApiDocsComponent implements OnInit, AfterViewInit {
|
export class ApiDocsComponent implements OnInit, AfterViewInit {
|
||||||
|
private destroy$: Subject<any> = new Subject<any>();
|
||||||
plainHostname = document.location.hostname;
|
plainHostname = document.location.hostname;
|
||||||
electrsPort = 0;
|
electrsPort = 0;
|
||||||
hostname = document.location.hostname;
|
hostname = document.location.hostname;
|
||||||
@ -82,7 +83,7 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
|
|||||||
this.restDocs = restApiDocsData;
|
this.restDocs = restApiDocsData;
|
||||||
this.wsDocs = wsApiDocsData;
|
this.wsDocs = wsApiDocsData;
|
||||||
|
|
||||||
this.network$.subscribe((network) => {
|
this.network$.pipe(takeUntil(this.destroy$)).subscribe((network) => {
|
||||||
this.active = (network === 'liquid' || network === 'liquidtestnet') ? 2 : 0;
|
this.active = (network === 'liquid' || network === 'liquidtestnet') ? 2 : 0;
|
||||||
switch( network ) {
|
switch( network ) {
|
||||||
case "":
|
case "":
|
||||||
@ -102,6 +103,8 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next(true);
|
||||||
|
this.destroy$.complete();
|
||||||
window.removeEventListener('scroll', this.onDocScroll);
|
window.removeEventListener('scroll', this.onDocScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user