mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove dead code
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a3639e66bf
commit
4326c5ab86
@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { DiContainerForInjection, Injectable } from "@ogre-tools/injectable";
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import type { InitializableStateValue } from "./create";
|
|
||||||
|
|
||||||
export interface CreateLazyInitializableStateArgs<T> {
|
|
||||||
id: string;
|
|
||||||
init: (di: DiContainerForInjection) => T;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LazyInitializableState<T> {
|
|
||||||
get: () => T;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createLazyInitializableState<T>(args: CreateLazyInitializableStateArgs<T>): Injectable<LazyInitializableState<T>, unknown, void> {
|
|
||||||
const { id, init } = args;
|
|
||||||
|
|
||||||
return getInjectable({
|
|
||||||
id,
|
|
||||||
instantiate: (di): LazyInitializableState<T> => {
|
|
||||||
let box: InitializableStateValue<T> = {
|
|
||||||
set: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
get: () => {
|
|
||||||
if (box.set === false) {
|
|
||||||
box = {
|
|
||||||
set: true,
|
|
||||||
value: init(di),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return box.value;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user