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:
parent
e6ed0c28a3
commit
281103c46e
@ -23,6 +23,8 @@
|
||||
this.cache_[namespace] = {};
|
||||
}
|
||||
|
||||
var deferred = Q.defer();
|
||||
|
||||
var cache = this.cache_[namespace];
|
||||
|
||||
var firstCacheKey = frame.getHash();
|
||||
@ -35,21 +37,20 @@
|
||||
processedFrame = this.outputCloner(cache[secondCacheKey], frame);
|
||||
cache[firstCacheKey] = processedFrame;
|
||||
} else {
|
||||
var deferred = Q.defer();
|
||||
this.frameProcessor(frame, this.onFrameProcessorComplete.bind(this, deferred, cache, firstCacheKey, secondCacheKey));
|
||||
return deferred.promise;
|
||||
}
|
||||
}
|
||||
|
||||
if (processedFrame) {
|
||||
return Q.fcall(processedFrame);
|
||||
deferred.resolve(processedFrame);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
ns.AsyncCachedFrameProcessor.prototype.onFrameProcessorComplete = function (deferred, cache, firstCacheKey, secondCacheKey, processedFrame) {
|
||||
cache[secondCacheKey] = processedFrame;
|
||||
cache[firstCacheKey] = processedFrame;
|
||||
console.log('RESOLVING');
|
||||
deferred.resolve(processedFrame);
|
||||
}
|
||||
})();
|
@ -58,8 +58,6 @@
|
||||
return this.cachedFrameProcessor.get(frame);
|
||||
}.bind(this))
|
||||
).done(function (results) {
|
||||
console.log('ALL DONE');
|
||||
|
||||
var colors = {};
|
||||
results.forEach(function (result) {
|
||||
Object.keys(result).forEach(function (color) {
|
||||
|
Loading…
Reference in New Issue
Block a user