mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
refactor: extract startup lifecycle hooks orchestration
This commit is contained in:
44
src/core/services/startup-lifecycle-hooks-runtime-service.ts
Normal file
44
src/core/services/startup-lifecycle-hooks-runtime-service.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { AppLifecycleDepsRuntimeOptions } from "./app-lifecycle-deps-runtime-service";
|
||||
import {
|
||||
AppReadyRuntimeDeps,
|
||||
runAppReadyRuntimeService,
|
||||
} from "./app-ready-runtime-service";
|
||||
import {
|
||||
AppShutdownRuntimeDeps,
|
||||
runAppShutdownRuntimeService,
|
||||
} from "./app-shutdown-runtime-service";
|
||||
import {
|
||||
createStartupAppReadyDepsRuntimeService,
|
||||
createStartupAppShutdownDepsRuntimeService,
|
||||
} from "./startup-lifecycle-runtime-deps-service";
|
||||
|
||||
type StartupLifecycleHookDeps = Pick<
|
||||
AppLifecycleDepsRuntimeOptions,
|
||||
"onReady" | "onWillQuitCleanup" | "shouldRestoreWindowsOnActivate" | "restoreWindowsOnActivate"
|
||||
>;
|
||||
|
||||
export interface StartupLifecycleHooksRuntimeOptions {
|
||||
appReadyDeps: AppReadyRuntimeDeps;
|
||||
appShutdownDeps: AppShutdownRuntimeDeps;
|
||||
shouldRestoreWindowsOnActivate: () => boolean;
|
||||
restoreWindowsOnActivate: () => void;
|
||||
}
|
||||
|
||||
export function createStartupLifecycleHooksRuntimeService(
|
||||
options: StartupLifecycleHooksRuntimeOptions,
|
||||
): StartupLifecycleHookDeps {
|
||||
return {
|
||||
onReady: async () => {
|
||||
await runAppReadyRuntimeService(
|
||||
createStartupAppReadyDepsRuntimeService(options.appReadyDeps),
|
||||
);
|
||||
},
|
||||
onWillQuitCleanup: () => {
|
||||
runAppShutdownRuntimeService(
|
||||
createStartupAppShutdownDepsRuntimeService(options.appShutdownDeps),
|
||||
);
|
||||
},
|
||||
shouldRestoreWindowsOnActivate: options.shouldRestoreWindowsOnActivate,
|
||||
restoreWindowsOnActivate: options.restoreWindowsOnActivate,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user