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

Simplify logic for registering general catalog entity sources

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-03-31 08:35:11 +03:00
parent 0e92d1d1f8
commit bfd08578ae
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 8 additions and 18 deletions

View File

@ -1,14 +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 { generalCatalogEntityInjectionToken } from "./general-catalog-entity-injection-token";
const generalCatalogEntitiesInjectable = getInjectable({
id: "general-catalog-entities",
instantiate: (di) => di.injectMany(generalCatalogEntityInjectionToken),
});
export default generalCatalogEntitiesInjectable;

View File

@ -3,20 +3,24 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import generalCatalogEntitiesInjectable from "../../common/catalog-entities/general-catalog-entities/general-catalog-entities.injectable";
import catalogEntityRegistryInjectable from "../catalog/catalog-entity-registry.injectable"; import catalogEntityRegistryInjectable from "../catalog/catalog-entity-registry.injectable";
import { generalCatalogEntityInjectionToken } from "../../common/catalog-entities/general-catalog-entities/general-catalog-entity-injection-token";
import { computed } from "mobx";
const syncGeneralCatalogEntitiesInjectable = getInjectable({ const syncGeneralCatalogEntitiesInjectable = getInjectable({
id: "sync-general-catalog-entities", id: "sync-general-catalog-entities",
instantiate: (di) => { instantiate: (di) => {
const generalCatalogEntities = di.inject(generalCatalogEntitiesInjectable); const generalCatalogEntities = di.injectMany(generalCatalogEntityInjectionToken);
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable); const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
// TODO: This shouldn't be reactive at all but catalogEntityRegistry accepts only reactive sources
const reactiveGeneralCatalogEntities = computed(() => generalCatalogEntities);
return () => { return () => {
catalogEntityRegistry.addObservableSource( catalogEntityRegistry.addComputedSource(
"lens:general", "lens:general",
generalCatalogEntities, reactiveGeneralCatalogEntities,
); );
}; };
}, },