Commit d0d50b16 authored by Tristan Cavelier's avatar Tristan Cavelier

JIO uses promy library now

parent 6eb3443c
...@@ -160,13 +160,11 @@ IODeferred.createFromDeferred = function (method, info, options, deferred) { ...@@ -160,13 +160,11 @@ IODeferred.createFromDeferred = function (method, info, options, deferred) {
// fail(deferred.reject.bind(deferred)). // fail(deferred.reject.bind(deferred)).
// progress(deferred.notify.bind(deferred)); // progress(deferred.notify.bind(deferred));
// // phantomjs doesn't like 'bind'... // // phantomjs doesn't like 'bind'...
iodeferred.promise().done(function () { iodeferred.promise.then(
deferred.resolve.apply(deferred, arguments); deferred.resolve.bind(deferred),
}).fail(function () { deferred.reject.bind(deferred),
deferred.reject.apply(deferred, arguments); deferred.notify.bind(deferred)
}).progress(function () { );
deferred.notify.apply(deferred, arguments);
});
return iodeferred; return iodeferred;
}; };
......
This diff is collapsed.
...@@ -315,7 +315,7 @@ function readBlobAsBinaryString(blob) { ...@@ -315,7 +315,7 @@ function readBlobAsBinaryString(blob) {
fr.onerror = deferred.reject.bind(deferred); fr.onerror = deferred.reject.bind(deferred);
fr.onprogress = deferred.notify.bind(deferred); fr.onprogress = deferred.notify.bind(deferred);
fr.readAsBinaryString(blob); fr.readAsBinaryString(blob);
return deferred.promise(); return deferred.promise;
} }
exports.util.readBlobAsBinaryString = readBlobAsBinaryString; exports.util.readBlobAsBinaryString = readBlobAsBinaryString;
...@@ -325,7 +325,7 @@ function readBlobAsArrayBuffer(blob) { ...@@ -325,7 +325,7 @@ function readBlobAsArrayBuffer(blob) {
fr.onerror = deferred.reject.bind(deferred); fr.onerror = deferred.reject.bind(deferred);
fr.onprogress = deferred.notify.bind(deferred); fr.onprogress = deferred.notify.bind(deferred);
fr.readAsArrayBuffer(blob); fr.readAsArrayBuffer(blob);
return deferred.promise(); return deferred.promise;
} }
exports.util.readBlobAsArrayBuffer = readBlobAsArrayBuffer; exports.util.readBlobAsArrayBuffer = readBlobAsArrayBuffer;
...@@ -335,7 +335,7 @@ function readBlobAsText(blob) { ...@@ -335,7 +335,7 @@ function readBlobAsText(blob) {
fr.onerror = deferred.reject.bind(deferred); fr.onerror = deferred.reject.bind(deferred);
fr.onprogress = deferred.notify.bind(deferred); fr.onprogress = deferred.notify.bind(deferred);
fr.readAsText(blob); fr.readAsText(blob);
return deferred.promise(); return deferred.promise;
} }
exports.util.readBlobAsText = readBlobAsText; exports.util.readBlobAsText = readBlobAsText;
...@@ -377,7 +377,7 @@ function ajax(param) { ...@@ -377,7 +377,7 @@ function ajax(param) {
param.beforeSend(xhr); param.beforeSend(xhr);
} }
xhr.send(param.data); xhr.send(param.data);
return deferred.promise(); return deferred.promise;
} }
exports.util.ajax = ajax; exports.util.ajax = ajax;
......
...@@ -20,7 +20,7 @@ function enableJobChecker(jio, shared, options) { ...@@ -20,7 +20,7 @@ function enableJobChecker(jio, shared, options) {
shared.job_rule_actions = { shared.job_rule_actions = {
wait: function (original_job, new_job) { wait: function (original_job, new_job) {
original_job.deferred.promise().always(function () { original_job.deferred.promise.always(function () {
shared.emit('job', new_job); shared.emit('job', new_job);
}); });
new_job.state = 'waiting'; new_job.state = 'waiting';
...@@ -35,7 +35,7 @@ function enableJobChecker(jio, shared, options) { ...@@ -35,7 +35,7 @@ function enableJobChecker(jio, shared, options) {
if (!original_job.deferred) { if (!original_job.deferred) {
original_job.deferred = new_job.deferred; original_job.deferred = new_job.deferred;
} else { } else {
original_job.deferred.promise(). original_job.deferred.promise.
done(new_job.command.resolve). done(new_job.command.resolve).
fail(new_job.command.reject); fail(new_job.command.reject);
} }
......
...@@ -52,7 +52,7 @@ function enableRestAPI(jio, shared) { // (jio, shared, options) ...@@ -52,7 +52,7 @@ function enableRestAPI(jio, shared) { // (jio, shared, options)
param.options = deepClone(type_dict.object.shift()) || {}; param.options = deepClone(type_dict.object.shift()) || {};
//param.deferred = new IODeferred(method, param.kwargs, param.options); //param.deferred = new IODeferred(method, param.kwargs, param.options);
param.deferred = new Deferred(); param.deferred = new Deferred();
promise = param.deferred.promise(); promise = param.deferred.promise;
type_dict['function'] = type_dict['function'] || []; type_dict['function'] = type_dict['function'] || [];
if (type_dict['function'].length === 1) { if (type_dict['function'].length === 1) {
callback = type_dict['function'].shift(); callback = type_dict['function'].shift();
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(exports); return module(exports, require('promy'), require('sha256'));
} }
window.jIO = {}; window.jIO = {};
module(window.jIO, {hex_sha256: hex_sha256}); module(window.jIO, promy, {hex_sha256: hex_sha256});
}(['exports', 'sha256'], function (exports, sha256) { }(['exports', 'promy', 'sha256'], function (exports, promy, sha256) {
"use strict"; "use strict";
var hex_sha256 = sha256.hex_sha256; var hex_sha256 = sha256.hex_sha256, Deferred = promy.Deferred;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment