chore(alert): removing the interceptor when destroying the util
This commit is contained in:
parent
0823df33b5
commit
fc7d5dc94e
@ -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() {
|
||||
|
||||
@ -3,6 +3,7 @@ import { Alerts, ALERTS_INITIALIZED_CLASS } from './alerts';
|
||||
const MOCK_APP = {
|
||||
httpClient: {
|
||||
addResponseInterceptor: () => {},
|
||||
removeResponseInterceptor: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user