repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: cleanup null checks and helpers
[e-mobility-charging-stations-simulator.git]
/
ui
/
web
/
src
/
composables
/
UIClient.ts
diff --git
a/ui/web/src/composables/UIClient.ts
b/ui/web/src/composables/UIClient.ts
index 7c0c06c121be0da21190687cc2ea752feb197fd3..ccd16c215565855d99ec0fa400bb7da0f8dd89bc 100644
(file)
--- a/
ui/web/src/composables/UIClient.ts
+++ b/
ui/web/src/composables/UIClient.ts
@@
-1,21
+1,21
@@
-import
Utils
from './Utils';
+import
{ promiseWithTimeout }
from './Utils';
import {
ProcedureName,
type ProtocolResponse,
type RequestPayload,
type ResponsePayload,
ResponseStatus,
import {
ProcedureName,
type ProtocolResponse,
type RequestPayload,
type ResponsePayload,
ResponseStatus,
-} from '@/types
/UIProtocol
';
+} from '@/types';
import config from '@/assets/config';
type ResponseHandler = {
procedureName: ProcedureName;
resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void;
import config from '@/assets/config';
type ResponseHandler = {
procedureName: ProcedureName;
resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void;
- reject: (reason?:
any
) => void;
+ reject: (reason?:
unknown
) => void;
};
export default class UIClient {
};
export default class UIClient {
- private static
_
instance: UIClient | null = null;
+ private static instance: UIClient | null = null;
private ws!: WebSocket;
private responseHandlers: Map<string, ResponseHandler>;
private ws!: WebSocket;
private responseHandlers: Map<string, ResponseHandler>;
@@
-26,10
+26,10
@@
export default class UIClient {
}
public static getInstance() {
}
public static getInstance() {
- if (UIClient.
_
instance === null) {
- UIClient.
_
instance = new UIClient();
+ if (UIClient.instance === null) {
+ UIClient.instance = new UIClient();
}
}
- return UIClient.
_
instance;
+ return UIClient.instance;
}
public registerWSonOpenListener(listener: (event: Event) => void) {
}
public registerWSonOpenListener(listener: (event: Event) => void) {
@@
-128,7
+128,7
@@
export default class UIClient {
id: string,
procedureName: ProcedureName,
resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void,
id: string,
procedureName: ProcedureName,
resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void,
- reject: (reason?:
any
) => void
+ reject: (reason?:
unknown
) => void
): void {
this.responseHandlers.set(id, { procedureName, resolve, reject });
}
): void {
this.responseHandlers.set(id, { procedureName, resolve, reject });
}
@@
-146,7
+146,7
@@
export default class UIClient {
data: RequestPayload
): Promise<ResponsePayload> {
let uuid: string;
data: RequestPayload
): Promise<ResponsePayload> {
let uuid: string;
- return
Utils.
promiseWithTimeout(
+ return promiseWithTimeout(
new Promise((resolve, reject) => {
uuid = crypto.randomUUID();
const msg = JSON.stringify([uuid, command, data]);
new Promise((resolve, reject) => {
uuid = crypto.randomUUID();
const msg = JSON.stringify([uuid, command, data]);