@robotlegsjs/core
Version:
An architecture-based IoC framework for JavaScript/TypeScript
125 lines (124 loc) • 4.77 kB
TypeScript
import { IEvent } from "../api/IEvent";
import { IEventDispatcher } from "../api/IEventDispatcher";
/**
* @private
*/
export interface IEventBin {
type: string;
listener: Function;
thisObject: any;
priority: number;
target: IEventDispatcher;
useCapture: boolean;
dispatchOnce: boolean;
}
/**
* The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements
* the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows
* any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface.
* Event targets are an important part of the Egret event model. The event target serves as the focal point for how events
* flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the
* event flow from the root of the display list. The event object then makes its way through the display list until it
* reaches the event target, at which point it begins its return trip through the display list. This round-trip journey
* to the event target is conceptually divided into three phases: <br/>
* the capture phase comprises the journey from the root to the last node before the event target's node, the target
* phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on
* the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event
* dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending
* another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple
* hooks to route calls into the aggregated EventDispatcher.
*
* @see egret.IEventDispatcher
* @version Egret 2.4
* @platform Web,Native
* @includeExample egret/events/EventDispatcher.ts
* @language en_US
*/
export declare class EventDispatcher implements IEventDispatcher {
/**
* @private
*/
private _eventDispatcher;
/**
* create an instance of the EventDispatcher class.
*
* @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when
* the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the
* containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
constructor(target?: IEventDispatcher);
/**
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
addEventListener(type: string, listener: Function, thisObject?: any, useCapture?: boolean, priority?: number): void;
/**
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
once(type: string, listener: Function, thisObject?: any, useCapture?: boolean, priority?: number): void;
/**
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
removeEventListener(type: string, listener: Function, thisObject?: any, useCapture?: boolean): void;
/**
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
hasEventListener(type: string): boolean;
/**
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
willTrigger(type: string): boolean;
/**
* @inheritDoc
* @version Egret 2.4
* @platform Web,Native
*/
dispatchEvent(event: IEvent): boolean;
/**
* Distribute a specified event parameters.
*
* @param type The type of the event. Event listeners can access this information through the inherited type property.
* @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through
* the inherited bubbles property.
* @param data {any} data
* @param cancelable Determines whether the Event object can be canceled. The default values is false.
* @version Egret 2.4
* @platform Web,Native
* @language en_US
*/
dispatchEventWith(type: string, bubbles?: boolean, data?: any, cancelable?: boolean): boolean;
/**
* @private
*
* @param useCapture
*/
private _getEventMap;
/**
* @private
*/
private _addListener;
/**
* @private
*/
private _insertEventBin;
/**
* @private
*/
private _removeEventBin;
/**
* @private
*/
private _notifyListener;
}