1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/catalog-sources/sync-general-catalog-entities.injectable.ts
Janne Savolainen bfd08578ae
Simplify logic for registering general catalog entity sources
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-03-31 15:13:36 +03:00

30 lines
1.1 KiB
TypeScript

/**
* 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 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({
id: "sync-general-catalog-entities",
instantiate: (di) => {
const generalCatalogEntities = di.injectMany(generalCatalogEntityInjectionToken);
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
// TODO: This shouldn't be reactive at all but catalogEntityRegistry accepts only reactive sources
const reactiveGeneralCatalogEntities = computed(() => generalCatalogEntities);
return () => {
catalogEntityRegistry.addComputedSource(
"lens:general",
reactiveGeneralCatalogEntities,
);
};
},
});
export default syncGeneralCatalogEntitiesInjectable;