UNPKG

@robotlegsjs/phaser

Version:

RobotlegsJS integration with Phaser Scene Manager

132 lines (131 loc) 6.83 kB
import { Event, IClass, IEvent, IEventDispatcher } from "@robotlegsjs/core"; import { IEventEmitterMap } from "../../localEventEmitterMap/api/IEventEmitterMap"; import { IMediator } from "../api/IMediator"; /** * Abstract mediator implementation used by `SceneMediator` and `ViewMediator` classes. */ export declare abstract class AbstractMediator implements IMediator { protected _eventEmitterMap: IEventEmitterMap; protected _eventDispatcher: IEventDispatcher; /** * @inheritDoc */ abstract initialize(): void; /** * @inheritDoc */ abstract destroy(): void; /** * Runs after the mediator has been destroyed. * Cleans up listeners mapped through the local EventEmitterMap. */ postDestroy(): void; /** * Use this method to listen for events dispatched by the `Phaser.Events.EventEmitter`. * All the registered listeners will be automatically removed when this mediator is destroyed. * * Call this method is the same as calling `on` or `addListener` directly on the * `Phaser.Events.EventEmitter`, but keeps a list of listeners for easy (usually automatic) removal. * * The `context` will be automatically mapped to `this` when no context information is provided. * * @param emitter The `Phaser.Events.EventEmitter` to listen to * @param event The `event` type to listen for * @param listener The `event` handler * @param context The listener function's "this" */ protected on(emitter: Phaser.Events.EventEmitter, event: string | symbol, listener: Function, context?: any): void; /** * Use this method to listen for events dispatched by the `Phaser.Events.EventEmitter`. * All the registered listeners will be automatically removed when this mediator is destroyed. * * Call this method is the same as calling `once` directly on the * `Phaser.Events.EventEmitter`, but keeps a list of listeners for easy (usually automatic) removal. * * The `context` will be automatically mapped to `this` when no context information is provided. * * @param emitter The `Phaser.Events.EventEmitter` to listen to * @param event The `event` type to listen for * @param listener The `event` handler * @param context The listener function's "this" */ protected once(emitter: Phaser.Events.EventEmitter, event: string | symbol, listener: Function, context?: any): void; /** * Use this method to remove listeners from events dispatched by the `Phaser.Events.EventEmitter`. * * Call this method is the same as calling `off` directly on the * `Phaser.Events.EventEmitter` emitter, but updates our local list of listeners. * * The `context` will be automatically mapped to `this` when no context information is provided. * * @param emitter The `Phaser.Events.EventEmitter` to listen to * @param event The `event` type to listen for * @param listener The `event` handler * @param contextt The listener function's "this" */ protected off(emitter: Phaser.Events.EventEmitter, event: string | symbol, listener: Function, context?: any): void; /** * Use this method to listen for events dispatched by the `EventDispatcher/code> provided by RobotlegsJS core. * * Call this method is the same as calling `addEventListener` directly on the * `EventDispatcher`, but keeps a list of listeners for easy (usually automatic) removal. * * The `context` will be automatically set to `this` when no context information is provided. * * @param event The `event` type to listen for * @param listener The `event` handler * @param context The listener function's "this" * @param eventClass Optional Event class for a stronger mapping. * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. * @param priority The priority level of the event listener. */ protected addContextListener(event: string, listener: Function, context?: any, eventClass?: IClass<IEvent>, useCapture?: boolean, priority?: number): void; /** * Use this method to remove listeners from events dispatched by the `EventDispatcher/code> provided by RobotlegsJS core. * * Call this method is the same as calling `removeEventListener` directly on the * `EventDispatcher`, but updates our local list of listeners. * * The `context` will be automatically set to `this` when no context information is provided. * * @param event The `event` type to listen for * @param listener The `event` handler * @param context The listener function's "this" * @param eventClass Optional Event class for a stronger mapping. * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. * @param priority The priority level of the event listener. */ protected removeContextListener(event: string, listener: Function, context?: any, eventClass?: IClass<IEvent>, useCapture?: boolean): void; /** * Use this method to listen for DOM events dispatched by the provided `EventTarget/code>. * * Call this method is the same as calling `addEventListener` directly on the * `EventTarget`, but keeps a list of listeners for easy (usually automatic) removal. * * @param eventTarget The `EventTarget` to listen to * @param event The `Event` type to listen for * @param listener The `Event` handler * @param options An options object that specifies characteristics about the event listener */ protected addDomListener(eventTarget: EventTarget, event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; /** * Use this method to remove listeners from DOM events dispatched by the provided `EventTarget/code>. * * Call this method is the same as calling `removeEventListener` directly on the * `EventTarget`, but updates our local list of listeners. * * @param dispatcher The `EventTarget` * @param event The `Event` type * @param listener The `Event` handler * @param options An options object that specifies characteristics about the event listener */ protected removeDomListener(eventTarget: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void; /** * Use this method to dispatch events to the Robotlegs context through the `EventDispatcher/code> provided by RobotlegsJS core. * * Call this method to trigger the execution of commands, call external services or communicate with other mediators. * * @param event The `Event` to dispatch */ protected dispatch(event: Event): void; }