mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Switch buildVersion to use new Initializable
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
72a01cdc17
commit
1b96a94c14
26 files changed
+105
-152
No files matched your search
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { RequestChannel } from "@k8slens/messaging";
|
||||
import { getInitializable } from "../../../../common/initializable-state/create";
|
||||
|
||||
export const buildVersionInitializable = getInitializable<string>("build-version");
|
||||
|
||||
export const buildVersionChannel: RequestChannel<void, string> = {
|
||||
id: "build-version",
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
|
||||
import { getInjectablesForInitializable } from "../../../../common/initializable-state/create";
|
||||
import getBuildVersionInjectable from "../../../../main/electron-app/features/get-build-version.injectable";
|
||||
import { buildVersionInitializable } from "../common/token";
|
||||
|
||||
export const {
|
||||
stateInjectable: buildVersionStateInjectable,
|
||||
initializationInjectable: buildVersionInitializationInjectable,
|
||||
} = getInjectablesForInitializable({
|
||||
token: buildVersionInitializable,
|
||||
phase: beforeApplicationIsLoadingInjectionToken,
|
||||
init: (di) => {
|
||||
const getBuildVersion = di.inject(getBuildVersionInjectable);
|
||||
|
||||
return getBuildVersion();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getRequestChannelListenerInjectable } from "@k8slens/messaging";
|
||||
import { buildVersionChannel, buildVersionInitializable } from "../common/token";
|
||||
|
||||
const buildVersionChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
id: "build-version-channel-listener",
|
||||
channel: buildVersionChannel,
|
||||
getHandler: (di) => () => di.inject(buildVersionInitializable.stateToken),
|
||||
});
|
||||
|
||||
export default buildVersionChannelListenerInjectable;
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { requestFromChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { getInjectablesForInitializable } from "../../../../common/initializable-state/create";
|
||||
import { beforeFrameStartsSecondInjectionToken } from "../../../../renderer/before-frame-starts/tokens";
|
||||
import { buildVersionChannel, buildVersionInitializable } from "../common/token";
|
||||
|
||||
export const {
|
||||
stateInjectable: buildVersionStateInjectable,
|
||||
initializationInjectable: buildVersionInitializationInjectable,
|
||||
} = getInjectablesForInitializable({
|
||||
token: buildVersionInitializable,
|
||||
phase: beforeFrameStartsSecondInjectionToken,
|
||||
init: async (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return requestFromChannel(buildVersionChannel);
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user