1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/utils/with-orphan-promise/with-orphan-promise.injectable.ts
Janne Savolainen 191c0fa960
Fix incorrect name of file
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-06-03 07:49:47 +03:00

30 lines
1001 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import withErrorLoggingInjectable from "../with-error-logging/with-error-logging.injectable";
import { withErrorSuppression } from "../with-error-suppression/with-error-suppression";
import { pipeline } from "@ogre-tools/fp";
const withOrphanPromiseInjectable = getInjectable({
id: "with-orphan-promise",
instantiate: (di) => {
const withErrorLoggingFor = di.inject(withErrorLoggingInjectable);
return <T extends (...args: any[]) => Promise<any>>(toBeDecorated: T) =>
(...args: Parameters<T>): void => {
const decorated = pipeline(
toBeDecorated,
withErrorLoggingFor(() => "Orphan promise rejection encountered"),
withErrorSuppression,
);
decorated(...args);
};
},
});
export default withOrphanPromiseInjectable;