From c122f63a2046469788c2f7566f200950c7192dd5 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Sun, 6 Apr 2014 10:43:28 +0300 Subject: web client: reorder method --- web/transaction.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/web/transaction.js b/web/transaction.js index 8c91ff6..7c2101f 100644 --- a/web/transaction.js +++ b/web/transaction.js @@ -160,6 +160,11 @@ define( var tn = _.isObject(newValue); var npv = tn ? mpath : newValue; + var prevTask = mpath in invalid && + invalid[mpath][1] || $.Deferred().resolve(); + + invalid[mpath] = [npv, def]; + function ignore(path) { _.each(_.keys(invalid), function(p) { if (pth.isSubordinate(p, path)) @@ -180,7 +185,7 @@ define( def.resolve(isValid()); } - function validate() { + prevTask.always(function() { var del = newValue == null; var options; @@ -284,16 +289,8 @@ define( else resolve(); }).fail(reject); - } - - var prevTask; - if (mpath in invalid) prevTask = invalid[mpath][1]; - - invalid[mpath] = [npv, def]; - - if (prevTask) prevTask.always(validate); - else validate(); - + }); + return def; }; -- cgit v1.2.3