import type { TokenTraceConfig } from './TokenTrace';
export interface DispatchedEvent
> {
type: string;
payload: P;
}
interface EventBase {
payload: Payload;
eventId?: string;
targetId: string | null;
}
export interface EventArgs, TEvent = unknown> extends EventBase {
type: string;
originalEvent?: TEvent | null;
}
export interface BroadcastEventArgs> extends EventBase {
eventType: string;
}
export type BroadcastEventCallback = (args: BroadcastEventArgs) => void;
type CanHandleArgsWithType = CanHandleArgs & {
type: string;
};
/**
* Event canHandle() tests to see if the particular event type can be handled
*
* @param {CanHandleArgs} CanHandleArgs shape of the payload intersected with { type: string }
* @returns boolean
*/
export type EventCanHandle> = (payload: CanHandleArgsWithType, featureFlags?: Record) => boolean;
/**
* Event handle() will be called AFTER canHandle and ALWAYS returns a promise
*
* @param {EventActionPayload} EventActionPayload included `payload` object of event
* @param {EventHandlePromiseReturn} EventHandlePromiseReturn return type of the promise
*/
export type EventHandle = (event: EventArgs) => Promise;
/**
* Super generic event handler for Preset
*/
export interface EHRequired {
canHandle: EventCanHandle;
handle: EventHandle;
}
/**
* Capability strings that describe what UI features an event handler supports.
* These are used to conditionally render editor components in the DrilldownEditor.
*/
export type EventHandlerCapability = string;
export interface EventHandlerStatics {
defaultAppliedTokenFilters?: string[];
tokenTraceConfig?: TokenTraceConfig;
capabilities?: readonly EventHandlerCapability[];
}
export type AnyEventHandler = EHRequired;
type EHConstructable> = {
new (options?: O): R;
};
export type BaseEventHandler = EHConstructable & EventHandlerStatics;
export {};
//# sourceMappingURL=EventHandlers.d.ts.map