I have developed a JavaScript library that provides a class with an RxJS Subject. The class can be initialized and the Subject is accessible.
export class A {
private aSubject;
constructor() {
this.aSubject = new Subject();
}
public dispose() {
this.aSubject.complete();
}
}
Anyone who uses the above JavaScript library class:
const a = new A();
a.dispose();
My concern is, if a webpage is reloaded or refreshed without calling the dispose() method, could there be a memory leak for the incomplete Subject?
If there is a potential memory leak, how can I detect in my JavaScript library when a webpage is reloaded?