Search code examples
angularngx-toastr

ngx-toastr memory leak timeout


I have a memory leak issue in my application somewhere and I have code all over my project that looks like this

this.toastr.success("message sent!", "", {
                    timeOut: 2000
                  });

instead of

 this.timeout = this.toastr.success("message sent!", "", {
                    timeOut: 2000



  ngOnDestroy() {
    clearTimeout(this.timeout);
  }

and I was wondering if not assigning this.timeout to the toast so that I can clear it could be causing the memory leak?


Solution

  • Timeouts and clearing intervals and timeouts are handled in the toast.component.ts.

    So no, the library takes care of that.