'use strict';
Object.defineProperty(exports, '__esModule', {
    value: true
});
exports.default = void 0;
var _default = {
    lifetimes: {
        created: function () {
            this.nextCallback = null;
        },
        detached: function () {
            this.cancelNextCallback();
        }
    },
    methods: {
        safeSetData: function (t, a) {
            var that = this;
            this.pendingData = Object.assign({}, this, t);
            a = this.setNextCallback(a);
            this.setData(t, function () {
                that.pendingData = null;
                a();
            });
        },
        setNextCallback: function (a) {
            var that = this;
            var l = true;
            this.nextCallback = function (t) {
                if (l) {
                    l = false;
                    that.nextCallback = null;
                    a.call(that, t);
                }
            };
            this.nextCallback.cancel = function () {
                l = false;
            };
            return this.nextCallback;
        },
        cancelNextCallback: function () {
            if (null !== this.nextCallback) {
                this.nextCallback.cancel();
                this.nextCallback = null;
            }
        }
    }
};
exports.default = _default;
