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:
parent
0e92d1d1f8
commit
bfd08578ae
@ -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;
|
|
||||||
@ -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,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user