mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
wip : replace Job by promises
This commit is contained in:
committed by
juliandescottes
parent
522006f67a
commit
e6ed0c28a3
@@ -1,29 +0,0 @@
|
||||
(function () {
|
||||
var ns = $.namespace('pskl.utils');
|
||||
|
||||
ns.Job = function (cfg) {
|
||||
this.args = cfg.args;
|
||||
this.items = cfg.items;
|
||||
|
||||
this.process = cfg.process;
|
||||
this.onProcessEnd = cfg.onProcessEnd;
|
||||
this.onComplete = cfg.onComplete;
|
||||
|
||||
this.completed_ = 0;
|
||||
};
|
||||
|
||||
ns.Job.prototype.start = function () {
|
||||
this.items.forEach(function (item, index) {
|
||||
this.process(item, this.processCallback.bind(this, index));
|
||||
}.bind(this))
|
||||
};
|
||||
|
||||
ns.Job.prototype.processCallback = function (index, args) {
|
||||
this.completed_++;
|
||||
this.onProcessEnd(args, index);
|
||||
|
||||
if (this.completed_ === this.items.length) {
|
||||
this.onComplete(this.args);
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -24,7 +24,6 @@
|
||||
"js/utils/FileUtilsDesktop.js",
|
||||
"js/utils/FrameTransform.js",
|
||||
"js/utils/FrameUtils.js",
|
||||
"js/utils/Job.js",
|
||||
"js/utils/LayerUtils.js",
|
||||
"js/utils/ImageResizer.js",
|
||||
"js/utils/PixelUtils.js",
|
||||
|
||||
Reference in New Issue
Block a user