diff --git a/src/main/start-main-application/run-many-for.ts b/src/main/start-main-application/run-many-for.ts new file mode 100644 index 0000000000..10d73e5ea4 --- /dev/null +++ b/src/main/start-main-application/run-many-for.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import type { + DiContainerForInjection, + InjectionToken, +} from "@ogre-tools/injectable"; + +export interface Runnable { + run: (parameter: TParameter) => Promise | void; +} + +export const runManyFor = + (di: DiContainerForInjection) => + >( + injectionToken: InjectionToken, + ) => + async (parameter: Parameters[0]) => + await Promise.all( + di.injectMany(injectionToken).map((runnable) => runnable.run(parameter)), + );