UNPKG

@zxh19890103/wik

Version:

The world-class JavaScript library for building large-scale digital warehouse both on 2D and 3D.

61 lines (60 loc) 2.2 kB
import { EventNames } from 'eventemitter3'; import { SimpleObject } from '../../interfaces'; import { WikEvent } from './Event.class'; import { WithParent } from '../../interfaces'; /** * When you use this methods mixin, please keep in mind that the target Class you want mix must be inherited from EventEmitter */ export declare abstract class EmitterMix implements WithParent<EmitterMix> { $$parent: EmitterMix; noEmit: boolean; /** * @overrides */ fire(event: string, payload: any): any; emit(...args: any[]): void; setEventChild(child: EmitterMix, rm?: boolean): this; setEventParent(parent: EmitterMix): this; fire$n(event: string, payload: any): void; listen$n(event: string, handler: (event: WikEvent) => void): void; unlisten$n(event: string, handler?: (event: WikEvent) => void): void; } export declare const __global_event__: () => WikEvent<any, any>; export declare const __batched_fires__: <R = any>(fn: () => R | Promise<R>, event?: string) => R | Promise<void>; export interface WithEmitter<E extends string> { /** * set it True, the follow emit will be ignore and then set it False. */ noEmit: boolean; fire<T extends EventNames<E>>(event: T, payload?: SimpleObject): boolean; /** * split fire */ fire$n(event: string, payload?: SimpleObject): this; /** * on */ listen<T extends EventNames<E>>(event: T, fn: (event: WikEvent) => void, context?: any): this; /** * split on */ listen$n(event: string, fn: (event: WikEvent) => void): this; /** * off */ unlisten<T extends EventNames<E>>(event: T, fn?: (event: WikEvent) => void): this; /** * split off */ unlisten$n(event: string, fn?: (event: WikEvent) => void): this; /** * once */ listen$1<T extends EventNames<E>>(event: T, fn: (event: WikEvent) => void, context?: any): this; /** * Create parent-child relationships of two evented objects manually. * Because this method not mounted on evented object. */ setEventChild(child: WithEmitter<string>, off?: boolean): this; setEventParent(parent: WithEmitter<string>): this; }