UNPKG

@rontian/egret-robotlegs

Version:

Egret View Integration with RobotlegsJS

81 lines 4.03 kB
"use strict"; // ------------------------------------------------------------------------------ // Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved. // // NOTICE: You are permitted to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // ------------------------------------------------------------------------------ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var core_1 = require("@robotlegsjs/core"); var ConvertToEventDispatcher_1 = require("./ConvertToEventDispatcher"); /** * Classic Robotlegs mediator implementation * * <p>Override initialize and destroy to hook into the mediator lifecycle.</p> */ var Mediator = /** @class */ (function () { function Mediator() { } Object.defineProperty(Mediator.prototype, "view", { get: function () { return this._viewComponent; }, /*============================================================================*/ /* Public Properties */ /*============================================================================*/ set: function (view) { this._viewComponent = view; this._viewConverted = new ConvertToEventDispatcher_1.ConvertToEventDispatcher(this._viewComponent); }, enumerable: true, configurable: true }); /** * Runs after the mediator has been destroyed. * Cleans up listeners mapped through the local EventMap. */ Mediator.prototype.postDestroy = function () { this._eventMap.unmapAllListeners(); }; /*============================================================================*/ /* Protected Functions */ /*============================================================================*/ Mediator.prototype.addViewListener = function (eventString, listener, thisObject, eventClass, useCapture, priority) { this._eventMap.mapListener(this._viewConverted, eventString, listener, thisObject, eventClass, useCapture, priority); }; Mediator.prototype.addContextListener = function (eventString, listener, thisObject, eventClass, useCapture, priority) { this._eventMap.mapListener(this._eventDispatcher, eventString, listener, thisObject, eventClass, useCapture, priority); }; Mediator.prototype.addDomListener = function (eventTarget, eventString, listener, options) { this._eventMap.mapDomListener(eventTarget, eventString, listener, options); }; Mediator.prototype.removeViewListener = function (eventString, listener, thisObject, eventClass, useCapture) { this._eventMap.unmapListener(this._viewConverted, eventString, listener, thisObject, eventClass, useCapture); }; Mediator.prototype.removeContextListener = function (eventString, listener, thisObject, eventClass, useCapture) { this._eventMap.unmapListener(this._eventDispatcher, eventString, listener, thisObject, eventClass, useCapture); }; Mediator.prototype.removeDomListener = function (eventTarget, eventString, listener) { this._eventMap.unmapDomListener(eventTarget, eventString, listener); }; Mediator.prototype.dispatch = function (event) { if (this._eventDispatcher.hasEventListener(event.type)) { this._eventDispatcher.dispatchEvent(event); } }; tslib_1.__decorate([ core_1.inject(core_1.IEventMap), tslib_1.__metadata("design:type", Object) ], Mediator.prototype, "_eventMap", void 0); tslib_1.__decorate([ core_1.inject(core_1.IEventDispatcher), tslib_1.__metadata("design:type", Object) ], Mediator.prototype, "_eventDispatcher", void 0); Mediator = tslib_1.__decorate([ core_1.injectable() ], Mediator); return Mediator; }()); exports.Mediator = Mediator; //# sourceMappingURL=Mediator.js.map