chore(alert): removing the interceptor when destroying the util

This commit is contained in:
Johannes Eder 2021-08-03 17:35:10 +02:00 committed by Sarah Vaupel
parent 0823df33b5
commit fc7d5dc94e
2 changed files with 5 additions and 1 deletions

View File

@ -34,6 +34,7 @@ export class Alerts {
_app;
_eventManager;
_boundResponseInterceptor;
constructor(element, app) {
if (!element) {
@ -44,6 +45,7 @@ export class Alerts {
this._app = app;
this._eventManager = new EventManager();
this._boundResponseInterceptor = this._responseInterceptor.bind(this);
if (this._element.classList.contains(ALERTS_INITIALIZED_CLASS)) {
return false;
@ -68,6 +70,7 @@ export class Alerts {
destroy() {
this._eventManager.removeAllEventListenersFromUtil();
this._app.httpClient.removeResponseInterceptor(this._boundResponseInterceptor);
if(this._alertElements) {
this._alertElements.forEach(element => element.remove());
@ -135,7 +138,7 @@ export class Alerts {
}
_setupHttpInterceptor() {
this._app.httpClient.addResponseInterceptor(this._responseInterceptor.bind(this));
this._app.httpClient.addResponseInterceptor(this._boundResponseInterceptor);
}
_elevateAlerts() {

View File

@ -3,6 +3,7 @@ import { Alerts, ALERTS_INITIALIZED_CLASS } from './alerts';
const MOCK_APP = {
httpClient: {
addResponseInterceptor: () => {},
removeResponseInterceptor: () => {},
},
};