mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Typed catalog category events (#2812)
* typesafe catalog category events Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * use emit Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * rename events Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
c8e2f7ca2d
commit
cd96842750
6 files changed
+26
-6
No files matched your search
@@ -19,7 +19,8 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import EventEmitter from "events";
|
||||
import type TypedEmitter from "typed-emitter";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
|
||||
type ExtractEntityMetadataType<Entity> = Entity extends CatalogEntity<infer Metadata> ? Metadata : never;
|
||||
@@ -47,7 +48,13 @@ export interface CatalogCategorySpec {
|
||||
};
|
||||
}
|
||||
|
||||
export abstract class CatalogCategory extends EventEmitter {
|
||||
export interface CatalogCategoryEvents {
|
||||
load: () => void;
|
||||
catalogAddMenu: (context: CatalogEntityAddMenuContext) => void;
|
||||
contextMenuOpen: (entity: CatalogEntity, context: CatalogEntityContextMenuContext) => void;
|
||||
}
|
||||
|
||||
export abstract class CatalogCategory extends (EventEmitter as new () => TypedEmitter<CatalogCategoryEvents>) {
|
||||
abstract readonly apiVersion: string;
|
||||
abstract readonly kind: string;
|
||||
abstract metadata: {
|
||||
|
||||
Reference in new issue
Block a user