Skip to content

Commit c427a15

Browse files
committed
Singleton protection improved once again
1 parent f55a648 commit c427a15

5 files changed

Lines changed: 4 additions & 19 deletions

File tree

.github/workflows/npmPublish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
paths-ignore:
88
- '.github/workflows/*' # не запускать воркфлоу при обновлении самих воркфлоу
99
env:
10-
NPM_VERSION_MODIFIER: minor
10+
NPM_VERSION_MODIFIER: patch
1111
NODE_VERSION: 18.11.0
1212
jobs:
1313
Prepare_and_publish:

Connector.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ class Connector extends Singleton {
6969

7070
public lastEvent: T.RemoteEvent | null = null;
7171

72-
constructor() {
73-
super("Connector");
74-
};
75-
7672
public addEventListener(key: string, handler: (event: T.RemoteEvent) => any) {
7773
this._eventListenersTable[key] = handler;
7874
};

helpers/classes/Singleton.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ import { ObjectT } from "../../types";
33
export abstract class Singleton {
44
private static _classHasInstanceTable: ObjectT<boolean> = {};
55

6-
constructor(classId: string) {
7-
if (classId.length < 1)
8-
throw new Error("Non-empty classId required for Singleton class protection!");
9-
10-
if (Singleton._classHasInstanceTable[classId])
6+
constructor() {
7+
if (Singleton._classHasInstanceTable[this.constructor.name])
118
throw new Error("Attempted to create second instance of a Singleton class!");
129

13-
Singleton._classHasInstanceTable[classId] = true;
10+
Singleton._classHasInstanceTable[this.constructor.name] = true;
1411
}
1512
};

services/idService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ class IdService extends Singleton {
88
private _currentInterceptedTanStackQueryEventId = 0;
99
private _currentInterceptedMobxEventId = 0;
1010

11-
constructor() {
12-
super("IdService");
13-
}
14-
1511
public get currentInterceptedReduxActionId() {
1612
return `RA_${this._currentInterceptedReduxActionId++}`;
1713
}

services/remoteSettingsService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ class RemoteSettingsService extends Singleton {
2222
delete this._remoteSettingsListenersTable[key];
2323
};
2424

25-
constructor() {
26-
super("RemoteSettingsService");
27-
}
28-
2925
public onGotNewRemoteSettings(r: RemoteSettings) {
3026
if (!this._isInit)
3127
return;

0 commit comments

Comments
 (0)