gold-sight
Version:
Test your code on realistic content, precisely
78 lines • 4.69 kB
TypeScript
import { EventContext } from "../index.types";
type FilterOptions = {
includeOverwritten?: boolean;
includeRecursive?: boolean;
};
type IEvent = {
name: string;
payload?: any;
id?: string;
state?: any;
uuidStack: string[];
funcData: IFuncData;
eventUUID: string;
};
type IFuncData = {
funcName: string;
funcIndex: number;
};
declare class EventBus {
isEventBus: boolean;
constructor(events?: {
[name: string]: IEvent[];
});
events: {
[name: string]: IEvent[];
};
overwrittenEvents: {
[name: string]: IEvent[];
};
private emitOnceEvents;
emit(name: string, ctx: {
eventUUID?: string;
eventUUIDs?: string[];
funcData?: IFuncData;
}, payload?: any): IEvent;
emitOne(name: string, uuid: {
eventUUIDs?: string[];
}, key: any, payload?: any): IEvent;
emitOnce(name: string, ctx: {
eventUUID?: string;
eventUUIDs?: string[];
funcData?: IFuncData;
}, payload?: any): IEvent | null;
getAllEventsForUUID(uuid: string): IEvent[];
filterEventsByName(name: string, options?: FilterOptions): IEvent[];
getEventByState(name: string, state: any, options?: FilterOptions): IEvent | null;
getEventByPayload(name: string, payload: any, options?: FilterOptions): IEvent | null;
getEvent(name: string, payload: any, state: any, options?: FilterOptions): IEvent | null;
getEventByUUID(name: string, uuid: string, funcData?: FuncData, options?: FilterOptions): IEvent | null;
filterEventsByState(name: string, state: any, options?: FilterOptions): IEvent[];
filterEventsByPayload(name: string, payload: any, options?: FilterOptions): IEvent[];
filterEvents(name: string, payload: any, state: any, options?: FilterOptions): IEvent[];
}
declare function getEventBus(args: any[]): EventBus | null;
declare function getEventUUID(args: any[]): string | undefined;
declare function getFuncData(args: any[]): IFuncData | undefined;
declare function getEventByState(eventBus: EventBus, name: string, state: any, options?: Pick<FilterOptions, "includeOverwritten">): IEvent | null;
declare function getEventByPayload(eventBus: EventBus, name: string, payload: any, options?: Pick<FilterOptions, "includeOverwritten">): IEvent | null;
declare function getEvent(eventBus: EventBus, name: string, payload: any, state: any, options?: Pick<FilterOptions, "includeOverwritten">): IEvent | null;
type FuncData = {
funcName: string;
funcIndex: number;
};
declare function getEventByUUID(eventBus: EventBus, name: string, uuid: string, funcData?: FuncData, options?: FilterOptions): IEvent | null;
declare function filterRecursion(events: IEvent[], funcData: FuncData): IEvent[];
declare function filterRecursionForName(events: IEvent[], name: string): IEvent[];
declare function filterEventsByState(eventBus: EventBus, name: string, state: any, options?: Pick<FilterOptions, "includeOverwritten">): IEvent[];
declare function filterEventsByPayload(eventBus: EventBus, name: string, payload: any, options?: Pick<FilterOptions, "includeOverwritten">): IEvent[];
declare function filterEventsByUUID(events: IEvent[], uuid: string, funcData?: FuncData, options?: Pick<FilterOptions, "includeRecursive">): IEvent[];
declare function filterEvents(eventBus: EventBus, name: string, payload: any, state: any, options?: Pick<FilterOptions, "includeOverwritten">): IEvent[];
declare function withEventBus(args: any[], func: (eventBus: EventBus) => any): (...args: any[]) => any;
declare function withEvents(args: any[], func: (eventBus: EventBus, eventUUID: string, funcData: IFuncData) => any): (...args: any[]) => any;
declare function withEventNames(args: any[], eventNames: string[], func: (events: Record<string, IEvent>, eventBus: EventBus, eventUUID: string) => any, options?: FilterOptions): (...args: any[]) => any;
declare function withEventNamesList(args: any[], eventNames: string[], func: (events: Record<string, IEvent[]>, eventBus: EventBus, eventUUID: string) => any, options?: FilterOptions): (...args: any[]) => any;
declare function filterEventsByName(eventBus: EventBus, name: string, options?: Pick<FilterOptions, "includeOverwritten">): IEvent[];
declare function makeEventContext(): EventContext;
export { getEventBus, EventBus, IEvent, getEventByState, getEventByPayload, getEvent, filterEventsByState, filterEventsByPayload, filterEvents, getEventUUID, getEventByUUID, filterEventsByUUID, withEventBus, withEvents, withEventNames, getFuncData, filterEventsByName, IFuncData, makeEventContext, withEventNamesList, filterRecursion, filterRecursionForName, };
//# sourceMappingURL=eventBus.d.ts.map