DEV: Ensure presence beforeunload event listener is cleaned up
In production, services are singletons. This logic will only affect the test environment
This commit is contained in:
parent
54ca7a9618
commit
d43b77b56b
|
@ -227,9 +227,14 @@ export default class PresenceService extends Service {
|
||||||
this._presentProxies = {};
|
this._presentProxies = {};
|
||||||
this._subscribedProxies = {};
|
this._subscribedProxies = {};
|
||||||
this._initialDataRequests = {};
|
this._initialDataRequests = {};
|
||||||
window.addEventListener("beforeunload", () => {
|
|
||||||
this._beaconLeaveAll();
|
this._beforeUnloadCallback = () => this._beaconLeaveAll();
|
||||||
});
|
window.addEventListener("beforeunload", this._beforeUnloadCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
willDestroy() {
|
||||||
|
super.willDestroy(...arguments);
|
||||||
|
window.removeEventListener("beforeunload", this._beforeUnloadCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a PresenceChannel object representing a single channel
|
// Get a PresenceChannel object representing a single channel
|
||||||
|
|
Loading…
Reference in New Issue