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

Make runnables for before application is ready synchronous as this is technical limitation of Electron

See: https://github.com/electron/electron/issues/21370

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-28 12:42:25 +03:00
parent d4b2ff992a
commit 25a48f3d7d
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 7 additions and 3 deletions

View File

@ -3,9 +3,9 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectionToken } from "@ogre-tools/injectable";
import type { Runnable } from "../run-many-for";
import type { RunnableSync } from "../run-many-sync-for";
export const beforeApplicationIsReadyInjectionToken =
getInjectionToken<Runnable>({
getInjectionToken<RunnableSync>({
id: "before-application-is-ready",
});

View File

@ -8,16 +8,20 @@ import electronAppInjectable from "../electron-app/electron-app.injectable";
import { beforeApplicationIsReadyInjectionToken } from "./before-application-is-ready/before-application-is-ready-injection-token";
import { afterApplicationIsReadyInjectionToken } from "./after-application-is-ready/after-application-is-ready-injection-token";
import { runManyFor } from "./run-many-for";
import { runManySyncFor } from "./run-many-sync-for";
const startMainApplicationInjectable = getInjectable({
id: "start-main-application",
instantiate: (di) => {
const runMany = runManyFor(di);
const runManySync = runManySyncFor(di);
const app = di.inject(electronAppInjectable);
return async () => {
await runMany(beforeApplicationIsReadyInjectionToken)();
// Stuff happening before application is ready needs to be synchronous because of
// https://github.com/electron/electron/issues/21370
runManySync(beforeApplicationIsReadyInjectionToken)();
await app.whenReady();