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

Demonstrate a step further to have an interface as dependency instead of concrete instance

With this we get yet closer to satisfaction of Dependency Inversion Principle.

Signed-off-by: Janne Savolainen <janne.savolainen@houston-inc.com>
This commit is contained in:
Janne Savolainen 2021-11-04 09:51:28 +02:00 committed by Janne Savolainen
parent 8d0abcc9d5
commit 91b14ee3fc
2 changed files with 7 additions and 3 deletions

View File

@ -27,7 +27,11 @@ import type { KubeApi } from "./kube-api";
import type { KubeObject } from "./kube-object";
import { IKubeObjectRef, parseKubeApi, createKubeApiURL } from "./kube-api-parse";
export class ApiManager {
export interface IGettableStore {
getStore<TKubeObjectStore extends KubeObjectStore<KubeObject>>(api: string | KubeApi<KubeObject>): TKubeObjectStore | undefined;
}
export class ApiManager implements IGettableStore {
private apis = observable.map<string, KubeApi<KubeObject>>();
private stores = observable.map<string, KubeObjectStore<KubeObject>>();

View File

@ -26,8 +26,8 @@ import { MenuActions, MenuActionsProps } from "../menu/menu-actions";
import identity from "lodash/identity";
import type { KubeObjectMenuRegistry } from "../../../extensions/registries";
import type { ApiManager } from "../../../common/k8s-api/api-manager";
import type { CatalogEntityRegistry } from "../../api/catalog-entity-registry";
import type { IGettableStore } from "../../../common/k8s-api/api-manager";
export interface KubeObjectMenuProps<T> extends MenuActionsProps {
@ -37,7 +37,7 @@ export interface KubeObjectMenuProps<T> extends MenuActionsProps {
}
interface KubeObjectMenuDependencies<T> extends KubeObjectMenuProps<T>{
apiManager: ApiManager,
apiManager: IGettableStore,
hideDetails: Function,
editResourceTab: Function,
catalogEntityRegistry: CatalogEntityRegistry,