import * as React from "react";
export declare type EventPayloadObject = any;
export declare type EventMap
= {
[K in keyof P]: EventPayloadObject & {
type?: never;
};
};
export declare type Event
, T extends keyof P> = {
readonly type: T;
as(target: S): Event
;
asUnchecked(target: S): Event
;
asAnyUnchecked(target: S): Event
;
/**
* Return an object containing only the event payload specific key value pairs.
*/
extractPayload(): P[T];
} & P[T];
export interface EventSender = EventMap> {
fire(event_type: T, data?: Events[T], overrideTypeKey?: boolean): any;
/**
* Fire an event later by using setTimeout(..)
* @param event_type The target event to be fired
* @param data The payload of the event
* @param callback The callback will be called after the event has been successfully dispatched
*/
fire_later(event_type: T, data?: Events[T], callback?: () => void): any;
/**
* Fire an event, which will be delayed until the next animation frame.
* This ensures that all react components have been successfully mounted/unmounted.
* @param event_type The target event to be fired
* @param data The payload of the event
* @param callback The callback will be called after the event has been successfully dispatched
*/
fire_react(event_type: T, data?: Events[T], callback?: () => void): any;
}
export declare type EventDispatchType = "sync" | "later" | "react";
export interface EventConsumer {
handleEvent(mode: EventDispatchType, type: string, data: any): any;
}
export declare class Registry = EventMap> implements EventSender {
protected readonly registryUniqueId: any;
protected persistentEventHandler: {
[key: string]: ((event: any) => void)[];
};
protected oneShotEventHandler: {
[key: string]: ((event: any) => void)[];
};
protected genericEventHandler: ((event: any) => void)[];
protected consumer: EventConsumer[];
private ipcConsumer;
private debugPrefix;
private warnUnhandledEvents;
private pendingAsyncCallbacks;
private pendingAsyncCallbacksTimeout;
private pendingReactCallbacks;
private pendingReactCallbacksFrame;
static fromIpcDescription = EventMap>(description: IpcRegistryDescription): Registry;
constructor();
destroy(): void;
enableDebug(prefix: string): void;
disableDebug(): void;
enableWarnUnhandledEvents(): void;
disableWarnUnhandledEvents(): void;
fire(eventType: T, data?: Events[T], overrideTypeKey?: boolean): void;
fire_later(eventType: T, data?: Events[T], callback?: () => void): void;
fire_react(eventType: T, data?: Events[T], callback?: () => void): void;
on(event: T | T[], handler: (event: Event) => void): () => void;
one(event: T | T[], handler: (event: Event) => void): () => void;
off(handler: (event: Event) => void): any;
off(events: T | T[], handler: (event: Event) => void): any;
onAll(handler: (event: Event) => void): () => void;
offAll(handler: (event: Event) => void): void;
/**
* @param event
* @param handler
* @param condition If a boolean the event handler will only be registered if the condition is true
* @param reactEffectDependencies
*/
reactUse(event: T | T[], handler: (event: Event) => void, condition?: boolean, reactEffectDependencies?: any[]): any;
private doInvokeEvent;
private invokeAsyncCallbacks;
private invokeReactCallbacks;
registerHandler(handler: any, parentClasses?: boolean): void;
unregisterHandler(handler: any): void;
registerConsumer(consumer: EventConsumer): () => void;
unregisterConsumer(consumer: EventConsumer): void;
generateIpcDescription(): IpcRegistryDescription;
}
export declare type RegistryMap = {
[key: string]: any;
};
export declare function EventHandler(events: (keyof EventTypes) | (keyof EventTypes)[]): (target: any, propertyKey: string, _descriptor: PropertyDescriptor) => void;
export declare function ReactEventHandler, Events = any>(registry_callback: (object: ObjectClass) => Registry): (constructor: Function) => void;
export declare type IpcRegistryDescription = EventMap> = {
ipcChannelId: string;
};