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

Reimplement setup for catalog syncing using runnables instead of non-OCP in index.ts

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:12:56 +03:00
parent 0d3728dba3
commit 9a7741f7cd
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
3 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,27 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import catalogEntityRegistryInjectable from "../catalog/catalog-entity-registry.injectable";
import { startCatalogSyncToRenderer } from "../catalog-pusher";
const catalogSyncToRendererInjectable = getInjectable({
id: "catalog-sync-to-renderer",
instantiate: (di) => {
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
let disposer: () => void;
return {
start: () => {
disposer = startCatalogSyncToRenderer(catalogEntityRegistry);
},
stop: () => disposer?.(),
};
},
});
export default catalogSyncToRendererInjectable;

View File

@ -0,0 +1,25 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { onRootFrameRenderInjectionToken } from "../start-main-application/on-root-frame-render/on-root-frame-render-injection-token";
import catalogSyncToRendererInjectable from "./catalog-sync-to-renderer.injectable";
const startCatalogSyncWhenRootFrameIsRenderedInjectable = getInjectable({
id: "start-catalog-sync-when-root-frame-is-rendered",
instantiate: (di) => {
const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable);
return {
run: () => {
catalogSyncToRenderer.start();
},
};
},
injectionToken: onRootFrameRenderInjectionToken,
});
export default startCatalogSyncWhenRootFrameIsRenderedInjectable;

View File

@ -0,0 +1,25 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import catalogSyncToRendererInjectable from "./catalog-sync-to-renderer.injectable";
import { onApplicationCloseInjectionToken } from "../start-main-application/on-application-close/on-application-close-injection-token";
const stopCatalogSyncWhenApplicationIsClosedInjectable = getInjectable({
id: "stop-catalog-sync-when-application-is-closed",
instantiate: (di) => {
const catalogSyncToRenderer = di.inject(catalogSyncToRendererInjectable);
return {
run: () => {
catalogSyncToRenderer.stop();
},
};
},
injectionToken: onApplicationCloseInjectionToken,
});
export default stopCatalogSyncWhenApplicationIsClosedInjectable;