Cleanup and fix activate-entity

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2021-10-05 14:40:25 -04:00
1 parent c264d5f1e2
commit 87babc8f2c
10 files changed
+56 -79

No files matched your search

+4 -10
View File
@@ -23,6 +23,7 @@
import type { CatalogCategory, CatalogEntity } from "../../common/catalog";
import { catalogEntityRegistry as registry } from "../../renderer/api/catalog-entity-registry";
import type { CatalogEntityOnBeforeRun } from "../../renderer/api/catalog-entity-registry";
import type { Disposer } from "../../common/utils";
export { catalogCategoryRegistry as catalogCategories } from "../../common/catalog/catalog-category-registry";
export class CatalogEntityRegistry {
@@ -50,21 +51,14 @@ export class CatalogEntityRegistry {
}
/**
* Add a onBeforeRun hook to a catalog entity.
* Add a onRun hook to a catalog entity. If `onBeforeRun` was previously added then it will not be added again
* @param catalogEntityUid The uid of the catalog entity
* @param onBeforeRun The function that should return a boolean if the onBeforeRun of catalog entity should be triggered.
* @param onBeforeRun The function that should return a boolean if the onRun of catalog entity should be triggered.
* @returns A function to remove that hook
*/
addOnBeforeRun(entity: CatalogEntity, onBeforeRun: CatalogEntityOnBeforeRun) {
addOnBeforeRun(entity: CatalogEntity, onBeforeRun: CatalogEntityOnBeforeRun): Disposer {
return registry.addOnBeforeRun(entity, onBeforeRun);
}
/**
* Returns one catalog entity onBeforeRun by catalog entity uid
*/
onBeforeRun(entity: CatalogEntity): Promise<boolean> {
return registry.onBeforeRun(entity);
}
}
export const catalogEntities = new CatalogEntityRegistry();