# all files / TypeScript.NET/source/System/Tasks/ TaskHandlerBase.js

81.82% Statements 36/44
56% Branches 14/25
90.91% Functions 10/11
87.18% Lines 34/39

    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
    64

    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    17×
    17×

    1×

    6889×

    1×
    289×
    289×

    289×
    289×

    1×

    1×
    1×

    1×
    7998×
    7998×
    284×
    284×
    284×

    7714×

    1×

    1×
    1×
    1×

     /*!
     * @author electricessence / https://github.com/electricessence/
     * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
     */
    var __extends = (this && this.__extends) || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
    (function (factory) {
        Eif (typeof module === 'object' && typeof module.exports === 'object') {
            var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
        }
        else if (typeof define === 'function' && define.amd) {
            define(["require", "exports", "../Disposable/DisposableBase"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var DisposableBase_1 = require("../Disposable/DisposableBase");
        var TaskHandlerBase = (function (_super) {
            __extends(TaskHandlerBase, _super);
            function TaskHandlerBase() {
                _super.call(this);
                this._id = null;
            }
            Object.defineProperty(TaskHandlerBase.prototype, "isScheduled", {
                get: function () {
                    return !!this._id;
                },
                enumerable: true,
                configurable: true
            });
            TaskHandlerBase.prototype.execute = function (defer) {
                this.cancel();
                Iif (isNaN(defer) || defer < 0) {
                    this._onExecute();
                }
                else Eif (isFinite(defer)) {
                    this._id = setTimeout(TaskHandlerBase._handler, defer, this);
                }
            };
            TaskHandlerBase._handler = function (d) {
                d.cancel();
                d._onExecute();
            };
            TaskHandlerBase.prototype._onDispose = function () {
                this.cancel();
            };
            TaskHandlerBase.prototype.cancel = function () {
                var id = this._id;
                if (id) {
                    clearTimeout(id);
                    this._id = null;
                    return true;
                }
                return false;
            };
            return TaskHandlerBase;
        }(DisposableBase_1.DisposableBase));
        exports.TaskHandlerBase = TaskHandlerBase;
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = TaskHandlerBase;
    });
    //# sourceMappingURL=TaskHandlerBase.js.map