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 authored and Janne Savolainen committed 2021-12-04 12:16:33 +02:00
1 parent 8d0abcc9d5
commit 91b14ee3fc
2 files changed
+7 -3

No files matched your search

+5 -1
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>>();
@@ -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,