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

observable.set > observable.map

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen 2021-10-05 16:48:34 +03:00
parent 74eb89c361
commit c8631346ca
No known key found for this signature in database
GPG Key ID: 54B44603D251B788

View File

@ -39,10 +39,7 @@ export class CatalogEntityRegistry {
protected filters = observable.set<EntityFilter>([], { protected filters = observable.set<EntityFilter>([], {
deep: false, deep: false,
}); });
protected entityOnBeforeRun = observable.set<{ protected entityOnBeforeRun = observable.map<CatalogEntityUid, CatalogEntityOnBeforeRun>({}, {
catalogEntityUid: CatalogEntityUid;
onBeforeRun: CatalogEntityOnBeforeRun
}>([], {
deep: false, deep: false,
}); });
@ -186,22 +183,16 @@ export class CatalogEntityRegistry {
* @returns A function to remove that hook * @returns A function to remove that hook
*/ */
addOnBeforeRun(catalogEntityUid: CatalogEntityUid, onBeforeRun: CatalogEntityOnBeforeRun): Disposer { addOnBeforeRun(catalogEntityUid: CatalogEntityUid, onBeforeRun: CatalogEntityOnBeforeRun): Disposer {
this.entityOnBeforeRun.add({ this.entityOnBeforeRun.set(catalogEntityUid, onBeforeRun);
catalogEntityUid,
onBeforeRun,
});
return once(() => void this.entityOnBeforeRun.delete({ return once(() => void this.entityOnBeforeRun.delete(catalogEntityUid));
catalogEntityUid,
onBeforeRun,
}));
} }
/** /**
* Returns one catalog entity onBeforeRun by catalog entity uid * Returns one catalog entity onBeforeRun by catalog entity uid
*/ */
getOnBeforeRun(_catalogEntityUid: CatalogEntityUid): CatalogEntityOnBeforeRun | undefined { getOnBeforeRun(catalogEntityUid: CatalogEntityUid): CatalogEntityOnBeforeRun | undefined {
return Array.from(this.entityOnBeforeRun).find(({ catalogEntityUid }) => catalogEntityUid === _catalogEntityUid)?.onBeforeRun; return this.entityOnBeforeRun.get(catalogEntityUid);
} }
} }