fix: ensure OCPP request timeouting cancel it
[e-mobility-charging-stations-simulator.git] / ui / web / src / composables / Utils.ts
index 9e1277a84beaeea04d35c0ec4bcc6fd749a8b79c..07848f36d41b8a8f285ae817b117ddaf6bdb2178 100644 (file)
@@ -18,28 +18,6 @@ export const ifUndefined = <T>(value: T | undefined, isValue: T): T => {
 //   if (isIterable(obj) === false) cb();
 // };
 
-export const promiseWithTimeout = <T>(
-  promise: Promise<T>,
-  timeoutMs: number,
-  timeoutError: Error,
-  timeoutCallback: () => void = () => {
-    /* This is intentional */
-  },
-): Promise<T> => {
-  // Create a timeout promise that rejects in timeout milliseconds
-  const timeoutPromise = new Promise<never>((_, reject) => {
-    setTimeout(() => {
-      // FIXME: The original promise state shall be checked
-      timeoutCallback();
-      // FIXME: The original promise shall be canceled
-      reject(timeoutError);
-    }, timeoutMs);
-  });
-
-  // Returns a race between timeout promise and the passed promise
-  return Promise.race<T>([promise, timeoutPromise]);
-};
-
 // export const compose = <T>(...fns: ((arg: T) => T)[]): ((x: T) => T) => {
 //   return (x: T) => fns.reduceRight((y, fn) => fn(y), x);
 // };