all files / block-manager/services/ event-service.js

100% Statements 24/24
100% Branches 0/0
100% Functions 9/9
100% Lines 24/24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35   1390× 1390× 1390×   1390× 1390×   1390× 1390×   2210×   1829×   1829×   1390× 1390×        
define(["require", "exports", "../../common/constant", "../../common/constant"], function (require, exports, constants, constant_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var EventService = (function () {
        function EventService(manager) {
            this.parent = manager;
            this.blockChanges = [];
            this.addEventListener();
        }
        EventService.prototype.addEventListener = function () {
            this.parent.observer.on(constants.CLEAREVENTCHANGES, this.clearEventChanges, this);
            this.parent.observer.on(constant_1.events.destroy, this.destroy, this);
        };
        EventService.prototype.removeEventListener = function () {
            this.parent.observer.off(constants.CLEAREVENTCHANGES, this.clearEventChanges);
            this.parent.observer.off(constant_1.events.destroy, this.destroy);
        };
        EventService.prototype.addChange = function (change) {
            this.blockChanges.push(change);
        };
        EventService.prototype.getChanges = function () {
            return this.blockChanges;
        };
        EventService.prototype.clearEventChanges = function () {
            this.blockChanges = [];
        };
        EventService.prototype.destroy = function () {
            this.blockChanges = null;
            this.removeEventListener();
        };
        return EventService;
    }());
    exports.EventService = EventService;
});