mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce and use AsyncSyncBox
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
8a291cde9e
commit
dbd8e3bebc
5 files changed
+112
-33
No files matched your search
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { createAsyncSyncBox } from "../../../common/async-sync/create";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { buildVersionChannel } from "../../../common/vars/build-semantic-version.injectable";
|
||||
|
||||
const buildVersionAsyncSyncBoxInjectable = createAsyncSyncBox({
|
||||
id: "build-version",
|
||||
init: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return requestFromChannel(buildVersionChannel);
|
||||
},
|
||||
});
|
||||
|
||||
export default buildVersionAsyncSyncBoxInjectable;
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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 { buildVersionInjectionToken } from "../../../common/vars/build-semantic-version.injectable";
|
||||
import buildVersionAsyncSyncBoxInjectable from "./box.injectable";
|
||||
|
||||
const buildVersionInjectable = getInjectable({
|
||||
id: "build-version",
|
||||
instantiate: (di) => {
|
||||
const buildVersionAsyncSyncBox = di.inject(buildVersionAsyncSyncBoxInjectable);
|
||||
|
||||
return buildVersionAsyncSyncBox.get();
|
||||
},
|
||||
injectionToken: buildVersionInjectionToken,
|
||||
});
|
||||
|
||||
export default buildVersionInjectable;
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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 { beforeFrameStartsInjectionToken } from "../../before-frame-starts/before-frame-starts-injection-token";
|
||||
import buildVersionAsyncSyncBoxInjectable from "./box.injectable";
|
||||
|
||||
const initializeBuildVersionAsyncSyncBoxInjectable = getInjectable({
|
||||
id: "initialize-build-version-async-sync-box",
|
||||
instantiate: (di) => {
|
||||
const buildVersionAsyncSyncBox = di.inject(buildVersionAsyncSyncBoxInjectable);
|
||||
|
||||
return {
|
||||
run: () => buildVersionAsyncSyncBox.init(),
|
||||
};
|
||||
},
|
||||
injectionToken: beforeFrameStartsInjectionToken,
|
||||
});
|
||||
|
||||
export default initializeBuildVersionAsyncSyncBoxInjectable;
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* 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 { runInAction } from "mobx";
|
||||
import { requestFromChannelInjectionToken } from "../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { buildVersionChannel, buildVersionInjectionToken } from "../../common/vars/build-semantic-version.injectable";
|
||||
import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token";
|
||||
|
||||
const setupBuildVersionInjectable = getInjectable({
|
||||
id: "setup-build-version",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return {
|
||||
run: async () => {
|
||||
const buildVersion = await requestFromChannel(buildVersionChannel);
|
||||
|
||||
runInAction(() => {
|
||||
di.register(getInjectable({
|
||||
id: "build-version",
|
||||
instantiate: () => buildVersion,
|
||||
injectionToken: buildVersionInjectionToken,
|
||||
}));
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
injectionToken: beforeFrameStartsInjectionToken,
|
||||
});
|
||||
|
||||
export default setupBuildVersionInjectable;
|
||||
Reference in new issue
Block a user