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

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 91b14ee3fc
commit 29d0634729
2 files changed
+18 -10

No files matched your search

@@ -32,10 +32,13 @@ export interface KubeObjectMenuRegistration {
components: KubeObjectMenuComponents;
}
export class KubeObjectMenuRegistry extends BaseRegistry<KubeObjectMenuRegistration> {
getItemsForKind(kind: string, apiVersion: string) {
return this.getItems().filter((item) => {
return item.kind === kind && item.apiVersions.includes(apiVersion);
});
}
export interface IHasGettableItemsForKind {
getItemsForKind(kind: string, apiVersion: string): any;
}
export class KubeObjectMenuRegistry extends BaseRegistry<KubeObjectMenuRegistration> implements IHasGettableItemsForKind {
getItemsForKind = (kind: string, apiVersion: string) =>
this.getItems().filter((item) =>
item.kind === kind && item.apiVersions.includes(apiVersion),
);
}