UNPKG

@robotlegsjs/pixi

Version:
81 lines 3.8 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 }); exports.Mediator = void 0; var tslib_1 = require("tslib"); var core_1 = require("@robotlegsjs/core"); var eventemitter3_1 = require("@robotlegsjs/eventemitter3"); /** * 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; }, enumerable: false, 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) { this.eventMap.on(this._viewComponent, eventString, listener, thisObject); }; 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) { this.eventMap.off(this._viewComponent, eventString, listener, thisObject); }; 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(eventemitter3_1.IEventEmitterMap), 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