1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Consolidate setup events to more granular timeslots

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-04-27 11:10:12 +03:00
parent 6fe0c2fce5
commit 0d3728dba3
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
4 changed files with 21 additions and 13 deletions

View File

@ -3,12 +3,19 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import type { DiContainer } from "@ogre-tools/injectable"; import type { DiContainer } from "@ogre-tools/injectable";
import { setupableInjectionToken } from "./setupable-injection-token"; import { beforeApplicationIsReadyInjectionToken } from "../../main/start-main-application/before-application-is-ready/before-application-is-ready-injection-token";
import { onApplicationIsReadyInjectionToken } from "../../main/start-main-application/on-application-is-ready/on-application-is-ready-injection-token";
export const runSetups = async (di: DiContainer) => { export const runSetups = async (di: DiContainer) => {
await Promise.all( await Promise.all(
di di
.injectMany(setupableInjectionToken) .injectMany(beforeApplicationIsReadyInjectionToken)
.map((setupable) => setupable.runSetup()), .map((setupable) => setupable.run()),
);
await Promise.all(
di
.injectMany(onApplicationIsReadyInjectionToken)
.map((setupable) => setupable.run()),
); );
}; };

View File

@ -3,13 +3,11 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import type { AppPaths } from "../../common/app-paths/app-path-injection-token"; import type { AppPaths } from "../../common/app-paths/app-path-injection-token";
import getElectronAppPathInjectable from "./get-electron-app-path/get-electron-app-path.injectable"; import getElectronAppPathInjectable from "./get-electron-app-path/get-electron-app-path.injectable";
import setElectronAppPathInjectable from "./set-electron-app-path/set-electron-app-path.injectable"; import setElectronAppPathInjectable from "./set-electron-app-path/set-electron-app-path.injectable";
import appNameInjectable from "./app-name/app-name.injectable"; import appNameInjectable from "./app-name/app-name.injectable";
import directoryForIntegrationTestingInjectable from "./directory-for-integration-testing/directory-for-integration-testing.injectable"; import directoryForIntegrationTestingInjectable from "./directory-for-integration-testing/directory-for-integration-testing.injectable";
import { setupableInjectionToken } from "../../common/setupable-injection-token/setupable-injection-token";
import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable"; import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable";
import { pathNames } from "../../common/app-paths/app-path-names"; import { pathNames } from "../../common/app-paths/app-path-names";
import { fromPairs, map } from "lodash/fp"; import { fromPairs, map } from "lodash/fp";
@ -17,6 +15,9 @@ import { pipeline } from "@ogre-tools/fp";
import { appPathsIpcChannel } from "../../common/app-paths/app-path-injection-token"; import { appPathsIpcChannel } from "../../common/app-paths/app-path-injection-token";
import registerChannelInjectable from "./register-channel/register-channel.injectable"; import registerChannelInjectable from "./register-channel/register-channel.injectable";
import joinPathsInjectable from "../../common/path/join-paths.injectable"; import joinPathsInjectable from "../../common/path/join-paths.injectable";
import {
beforeApplicationIsReadyInjectionToken,
} from "../start-main-application/before-application-is-ready/before-application-is-ready-injection-token";
const setupAppPathsInjectable = getInjectable({ const setupAppPathsInjectable = getInjectable({
id: "setup-app-paths", id: "setup-app-paths",
@ -31,7 +32,7 @@ const setupAppPathsInjectable = getInjectable({
const joinPaths = di.inject(joinPathsInjectable); const joinPaths = di.inject(joinPathsInjectable);
return { return {
runSetup: () => { run: () => {
if (directoryForIntegrationTesting) { if (directoryForIntegrationTesting) {
setElectronAppPath("appData", directoryForIntegrationTesting); setElectronAppPath("appData", directoryForIntegrationTesting);
} }
@ -53,7 +54,7 @@ const setupAppPathsInjectable = getInjectable({
}; };
}, },
injectionToken: setupableInjectionToken, injectionToken: beforeApplicationIsReadyInjectionToken,
}); });
export default setupAppPathsInjectable; export default setupAppPathsInjectable;

View File

@ -5,8 +5,8 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { AppPaths, appPathsIpcChannel } from "../../common/app-paths/app-path-injection-token"; import { AppPaths, appPathsIpcChannel } from "../../common/app-paths/app-path-injection-token";
import getValueFromRegisteredChannelInjectable from "./get-value-from-registered-channel/get-value-from-registered-channel.injectable"; import getValueFromRegisteredChannelInjectable from "./get-value-from-registered-channel/get-value-from-registered-channel.injectable";
import { setupableInjectionToken } from "../../common/setupable-injection-token/setupable-injection-token";
import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable"; import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable";
import { onApplicationIsReadyInjectionToken } from "../../main/start-main-application/on-application-is-ready/on-application-is-ready-injection-token";
let syncAppPaths: AppPaths; let syncAppPaths: AppPaths;
@ -14,7 +14,7 @@ const setupAppPathsInjectable = getInjectable({
id: "setup-app-paths", id: "setup-app-paths",
instantiate: (di) => ({ instantiate: (di) => ({
runSetup: async () => { run: async () => {
const getValueFromRegisteredChannel = di.inject( const getValueFromRegisteredChannel = di.inject(
getValueFromRegisteredChannelInjectable, getValueFromRegisteredChannelInjectable,
); );
@ -27,7 +27,7 @@ const setupAppPathsInjectable = getInjectable({
}, },
}), }),
injectionToken: setupableInjectionToken, injectionToken: onApplicationIsReadyInjectionToken,
}); });
export default setupAppPathsInjectable; export default setupAppPathsInjectable;

View File

@ -5,13 +5,13 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { ipcChannelListenerInjectionToken } from "./ipc-channel-listener-injection-token"; import { ipcChannelListenerInjectionToken } from "./ipc-channel-listener-injection-token";
import registerIpcChannelListenerInjectable from "../app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable"; import registerIpcChannelListenerInjectable from "../app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable";
import { setupableInjectionToken } from "../../common/setupable-injection-token/setupable-injection-token"; import { onApplicationIsReadyInjectionToken } from "../../main/start-main-application/on-application-is-ready/on-application-is-ready-injection-token";
const registerIpcChannelListenersInjectable = getInjectable({ const registerIpcChannelListenersInjectable = getInjectable({
id: "register-ipc-channel-listeners", id: "register-ipc-channel-listeners",
instantiate: di => ({ instantiate: di => ({
runSetup: async () => { run: async () => {
const registerIpcChannelListener = di.inject(registerIpcChannelListenerInjectable); const registerIpcChannelListener = di.inject(registerIpcChannelListenerInjectable);
const listeners = di.injectMany(ipcChannelListenerInjectionToken); const listeners = di.injectMany(ipcChannelListenerInjectionToken);
@ -22,7 +22,7 @@ const registerIpcChannelListenersInjectable = getInjectable({
}, },
}), }),
injectionToken: setupableInjectionToken, injectionToken: onApplicationIsReadyInjectionToken,
}); });
export default registerIpcChannelListenersInjectable; export default registerIpcChannelListenersInjectable;