Skip to content

Commit 9f99658

Browse files
vbabichbmingles
andauthored
feat: Cherry-pick Made event details generic (deephaven#2476)
DH-18086: Making event details generic on TableUtils.makeCancelableTableEventPromise Co-authored-by: Brian Ingles <[email protected]>
1 parent 21a2dce commit 9f99658

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/jsapi-utils/src/TableUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,12 @@ export class TableUtils {
624624
* @param matcher Optional function to determine if the promise can be resolved or stays pending
625625
* @returns Resolves with the event data
626626
*/
627-
static makeCancelableTableEventPromise(
627+
static makeCancelableTableEventPromise<TEventDetails = unknown>(
628628
table: DhType.Table | DhType.TreeTable,
629629
eventName: string,
630630
timeout = 0,
631-
matcher: ((event: DhType.Event<unknown>) => boolean) | null = null
632-
): CancelablePromise<DhType.Event<unknown>> {
631+
matcher: ((event: DhType.Event<TEventDetails>) => boolean) | null = null
632+
): CancelablePromise<DhType.Event<TEventDetails>> {
633633
let eventCleanup: () => void;
634634
let timeoutId: ReturnType<typeof setTimeout>;
635635
let isPending = true;
@@ -639,7 +639,7 @@ export class TableUtils {
639639
isPending = false;
640640
reject(new TimeoutError(`Event "${eventName}" timed out.`));
641641
}, timeout);
642-
eventCleanup = table.addEventListener(eventName, event => {
642+
eventCleanup = table.addEventListener<TEventDetails>(eventName, event => {
643643
if (matcher != null && !matcher(event)) {
644644
log.debug2('Event triggered, but matcher returned false.');
645645
return;
@@ -650,7 +650,7 @@ export class TableUtils {
650650
isPending = false;
651651
resolve(event);
652652
});
653-
}) as CancelablePromise<DhType.Event<unknown>>;
653+
}) as CancelablePromise<DhType.Event<TEventDetails>>;
654654
wrappedPromise.cancel = () => {
655655
if (isPending) {
656656
log.debug2('Pending promise cleanup.');

0 commit comments

Comments
 (0)