Skip to content

Commit

Permalink
feat: Made event details generic (#2343)
Browse files Browse the repository at this point in the history
DH-18086: Making event details generic on
TableUtils.makeCancelableTableEventPromise
  • Loading branch information
bmingles authored Jan 16, 2025
1 parent 5f6c8d6 commit b3260f0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/jsapi-utils/src/TableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ export class TableUtils {
* @param matcher Optional function to determine if the promise can be resolved or stays pending
* @returns Resolves with the event data
*/
static makeCancelableTableEventPromise(
static makeCancelableTableEventPromise<TEventDetails = unknown>(
table: DhType.Table | DhType.TreeTable,
eventName: string,
timeout = 0,
matcher: ((event: DhType.Event<unknown>) => boolean) | null = null
): CancelablePromise<DhType.Event<unknown>> {
matcher: ((event: DhType.Event<TEventDetails>) => boolean) | null = null
): CancelablePromise<DhType.Event<TEventDetails>> {
let eventCleanup: () => void;
let timeoutId: ReturnType<typeof setTimeout>;
let isPending = true;
Expand All @@ -639,7 +639,7 @@ export class TableUtils {
isPending = false;
reject(new TimeoutError(`Event "${eventName}" timed out.`));
}, timeout);
eventCleanup = table.addEventListener(eventName, event => {
eventCleanup = table.addEventListener<TEventDetails>(eventName, event => {
if (matcher != null && !matcher(event)) {
log.debug2('Event triggered, but matcher returned false.');
return;
Expand All @@ -650,7 +650,7 @@ export class TableUtils {
isPending = false;
resolve(event);
});
}) as CancelablePromise<DhType.Event<unknown>>;
}) as CancelablePromise<DhType.Event<TEventDetails>>;
wrappedPromise.cancel = () => {
if (isPending) {
log.debug2('Pending promise cleanup.');
Expand Down

0 comments on commit b3260f0

Please sign in to comment.