Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Made event details generic #2343

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading