chore(client/ts): port type_widget

This commit is contained in:
Elian Doran
2025-01-14 19:12:29 +02:00
parent 353156e625
commit e16f4a1a71
3 changed files with 16 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
import utils from "../services/utils.js";
import type { CommandMappings, CommandNames } from "./app_context.js";
import type { CommandMappings, CommandNames, EventData, EventNames } from "./app_context.js";
/**
* Abstract class for all components in the Trilium's frontend.
@@ -65,11 +65,11 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {
return this.parent?.triggerEvent(name, data);
}
handleEventInChildren(name: string, data: unknown = {}) {
const promises = [];
handleEventInChildren<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null {
const promises: Promise<unknown>[] = [];
for (const child of this.children) {
const ret = child.handleEvent(name, data);
const ret = child.handleEvent(name, data) as Promise<void>;
if (ret) {
promises.push(ret);