Refactor runnables (#6528)

* Convert runManyFor to use composite

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Convert runManySyncFor to use composite and to enfore sync-ness

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Remove dead code

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Convert getStartableStoppable to be always sync as it is never used in an async fashion

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Convert all sync runnables to comply with new checks for sync-ness

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-11-07 19:04:56 +02:00
1 parent 82ab60d544
commit b498f12186
42 files changed
+191 -401

No files matched your search

@@ -5,7 +5,6 @@
import { getInjectionToken } from "@ogre-tools/injectable";
import type { RunnableSync } from "../../../common/runnable/run-many-sync-for";
export const beforeElectronIsReadyInjectionToken =
getInjectionToken<RunnableSync>({
id: "before-electron-is-ready",
});
export const beforeElectronIsReadyInjectionToken = getInjectionToken<RunnableSync>({
id: "before-electron-is-ready",
});
@@ -5,7 +5,6 @@
import { getInjectionToken } from "@ogre-tools/injectable";
import type { RunnableSync } from "../../../common/runnable/run-many-sync-for";
export const beforeQuitOfBackEndInjectionToken =
getInjectionToken<RunnableSync>({
id: "before-quit-of-back-end",
});
export const beforeQuitOfBackEndInjectionToken = getInjectionToken<RunnableSync>({
id: "before-quit-of-back-end",
});
@@ -5,7 +5,6 @@
import { getInjectionToken } from "@ogre-tools/injectable";
import type { RunnableSync } from "../../../common/runnable/run-many-sync-for";
export const beforeQuitOfFrontEndInjectionToken =
getInjectionToken<RunnableSync>({
id: "before-quit-of-front-end",
});
export const beforeQuitOfFrontEndInjectionToken = getInjectionToken<RunnableSync>({
id: "before-quit-of-front-end",
});
@@ -11,9 +11,7 @@ const cleanUpShellSessionsInjectable = getInjectable({
instantiate: () => ({
id: "clean-up-shell-sessions",
run: () => {
ShellSession.cleanup();
},
run: () => void ShellSession.cleanup(),
}),
injectionToken: beforeQuitOfBackEndInjectionToken,
@@ -16,6 +16,8 @@ const emitCloseToEventBusInjectable = getInjectable({
id: "emit-close-to-event-bus",
run: () => {
emitAppEvent({ name: "app", action: "close" });
return undefined;
},
};
},
@@ -20,6 +20,8 @@ const flagRendererAsNotLoadedInjectable = getInjectable({
// Todo: remove this kludge which enables out-of-place temporal dependency.
lensProtocolRouterMain.rendererLoaded = false;
});
return undefined;
},
};
},
@@ -14,9 +14,7 @@ const stopKubeConfigSyncInjectable = getInjectable({
return {
id: "stop-kube-config-sync",
run: () => {
kubeConfigSyncManager.stopSync();
},
run: () => void kubeConfigSyncManager.stopSync(),
};
},
@@ -15,7 +15,7 @@ const setupSentryInjectable = getInjectable({
return {
id: "setup-sentry",
run: () => initializeSentryReportingWith(initializeSentryOnMain),
run: () => void initializeSentryReportingWith(initializeSentryOnMain),
};
},
injectionToken: beforeElectronIsReadyInjectionToken,
@@ -20,6 +20,8 @@ const setupHardwareAccelerationInjectable = getInjectable({
if (hardwareAccelerationShouldBeDisabled) {
disableHardwareAcceleration();
}
return undefined;
},
};
},
@@ -16,6 +16,8 @@ const setupImmerInjectable = getInjectable({
// Required in `utils/storage-helper.ts`
Immer.setAutoFreeze(false); // allow to merge mobx observables
Immer.enableMapSet(); // allow to merge maps and sets
return undefined;
},
}),
@@ -21,6 +21,8 @@ const setupMobxInjectable = getInjectable({
// reactionRequiresObservable: true,
// observableRequiresReaction: true,
});
return undefined;
},
}),
@@ -34,6 +34,8 @@ const setupProxyEnvInjectable = getInjectable({
if (getCommandLineSwitch("proxy-server") !== "") {
process.env.HTTPS_PROXY = getCommandLineSwitch("proxy-server");
}
return undefined;
},
};
},
@@ -16,13 +16,13 @@ const stopClusterManagerInjectable = getInjectable({
id: "stop-cluster-manager",
run: () => {
clusterManager.stop();
return undefined;
},
};
},
injectionToken: beforeQuitOfFrontEndInjectionToken,
causesSideEffects: true,
});
export default stopClusterManagerInjectable;