2016-05-04 02:28:50 +00:00
|
|
|
"use strict";
|
|
|
|
/// <reference path="./typings/main.d.ts" />
|
|
|
|
var plugins = require("./taskbuffer.plugins");
|
|
|
|
var helpers = require("./taskbuffer.classes.helpers");
|
|
|
|
var Task = (function () {
|
2016-05-05 16:36:31 +00:00
|
|
|
function Task(optionsArg) {
|
|
|
|
if (!optionsArg) {
|
|
|
|
optionsArg = { taskFunction: function () { } };
|
|
|
|
}
|
2016-05-04 02:28:50 +00:00
|
|
|
var options = optionsArg;
|
2016-05-05 16:36:31 +00:00
|
|
|
this.task = optionsArg.taskFunction;
|
2016-05-04 02:28:50 +00:00
|
|
|
this.preTask = options.preTask;
|
|
|
|
this.afterTask = options.afterTask;
|
|
|
|
this.idle = true;
|
|
|
|
this.running = false;
|
2016-05-05 16:36:31 +00:00
|
|
|
this.buffered = options.buffered;
|
2016-05-04 02:28:50 +00:00
|
|
|
}
|
|
|
|
Task.prototype.trigger = function () {
|
|
|
|
var done = plugins.Q.defer();
|
2016-05-05 16:36:31 +00:00
|
|
|
return helpers.runTask(this);
|
2016-05-04 02:28:50 +00:00
|
|
|
};
|
|
|
|
;
|
|
|
|
Task.prototype.triggerBuffered = function () {
|
|
|
|
var done = plugins.Q.defer();
|
|
|
|
};
|
|
|
|
Object.defineProperty(Task.prototype, "state", {
|
|
|
|
get: function () {
|
|
|
|
return this._state;
|
|
|
|
},
|
|
|
|
set: function (stateArg) {
|
|
|
|
if (stateArg == "locked") {
|
|
|
|
this._state = "locked";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.error("state type");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
return Task;
|
|
|
|
}());
|
|
|
|
exports.Task = Task;
|
|
|
|
|
2016-05-05 16:36:31 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRhc2tidWZmZXI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