Skip to content

Commit b8095c1

Browse files
committed
Test without static
1 parent 646c021 commit b8095c1

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-commsmanager",
3-
"version": "1.0.19",
3+
"version": "1.0.20",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"scripts": {

src/components/CommsManager.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class CommsManager {
1313
private ws: WebSocket;
1414
private observers: { [id: string]: Function[] } = {};
1515
private pendingPromises: Map<string, PromiseHandlers> = new Map();
16-
private static timeoutId?: number;
16+
private timeoutId?: number;
1717
private static state: string = "idle";
1818
private static adress: string = "ws://127.0.0.1:7163";
1919
private static universe?: string;
@@ -74,7 +74,7 @@ export default class CommsManager {
7474
console.log(`Connection with ${CommsManager.adress} interrupted`);
7575
}
7676

77-
CommsManager.timeoutId = window.setTimeout(function () {
77+
this.timeoutId = window.setTimeout(function () {
7878
delete CommsManager.instance;
7979
CommsManager.instance = new CommsManager();
8080
}, 1000);
@@ -92,12 +92,11 @@ export default class CommsManager {
9292

9393
public static deleteInstance() {
9494
if (CommsManager.instance) {
95+
if (CommsManager.instance.timeoutId) {
96+
window.clearTimeout(CommsManager.instance.timeoutId);
97+
}
9598
delete CommsManager.instance;
9699
CommsManager.instance = undefined;
97-
if (CommsManager.timeoutId) {
98-
window.clearTimeout(CommsManager.timeoutId);
99-
CommsManager.timeoutId = undefined;
100-
}
101100
}
102101
}
103102

0 commit comments

Comments
 (0)