Code coverage report for cjs/scheduler/FutureAction.js

Statements: 90.91% (50 / 55)      Branches: 71.43% (15 / 21)      Functions: 100% (9 / 9)      Lines: 92% (46 / 50)      Ignored: none     

All files » cjs/scheduler/ » FutureAction.js
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 641 1 1 1   1 1 1 1 1 55 55 55   1 147     147   1 154 154     154   1 27 27 27 27 27 27       27 22 22 22 22   27   1 50 50 50 50 5 5   50 2   50 50 50   1   1  
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var root_1 = require('../util/root');
var Subscription_1 = require('../Subscription');
var FutureAction = (function (_super) {
    __extends(FutureAction, _super);
    function FutureAction(scheduler, work) {
        _super.call(this);
        this.scheduler = scheduler;
        this.work = work;
    }
    FutureAction.prototype.execute = function () {
        Iif (this.isUnsubscribed) {
            throw new Error('How did did we execute a canceled Action?');
        }
        this.work(this.state);
    };
    FutureAction.prototype.schedule = function (state, delay) {
        if (delay === void 0) { delay = 0; }
        Iif (this.isUnsubscribed) {
            return this;
        }
        return this._schedule(state, delay);
    };
    FutureAction.prototype._schedule = function (state, delay) {
        var _this = this;
        Iif (delay === void 0) { delay = 0; }
        this.delay = delay;
        this.state = state;
        var id = this.id;
        Iif (id != null) {
            this.id = undefined;
            root_1.root.clearTimeout(id);
        }
        this.id = root_1.root.setTimeout(function () {
            _this.id = null;
            var scheduler = _this.scheduler;
            scheduler.actions.push(_this);
            scheduler.flush();
        }, delay);
        return this;
    };
    FutureAction.prototype._unsubscribe = function () {
        var _a = this, id = _a.id, scheduler = _a.scheduler;
        var actions = scheduler.actions;
        var index = actions.indexOf(this);
        if (id != null) {
            this.id = null;
            root_1.root.clearTimeout(id);
        }
        if (index !== -1) {
            actions.splice(index, 1);
        }
        this.work = null;
        this.state = null;
        this.scheduler = null;
    };
    return FutureAction;
})(Subscription_1.Subscription);
exports.FutureAction = FutureAction;
//# sourceMappingURL=FutureAction.js.map