I am facing an issue with a code that appears to be leaking, and I am seeking advice on how to identify the cause or properly unsubscribe. Even after adding an array containing all object subscriptions, the memory leakage persists.
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { of } from 'rxjs';
import { delay, tap, mergeMap, repeat } from 'rxjs/operators';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
postId;
callOmni = () => of(this.pollOmni()).pipe();
display = response => {};
poll = of({}).pipe(
mergeMap(_ => this.callOmni()),
tap(this.display),
delay(10),
repeat()
);
constructor(private http: HttpClient) { }
pollOmni() {
// Simple POST request with a JSON body and response type <any>
this.http.post<any>('http://127.0.0.1:8084/api', { call: 'getinfo' }).subscribe(
data => {
this.postId = data;
console.log(this.postId);
}),
error => {
console.log('oops', error)
}
}
ngOnInit() {
// Simple POST request with a JSON body and response type <any>
this.poll.subscribe();
}
}