[Pkg-javascript-commits] [backbone] 98/211: A somewhat smarter approach (more DRY).

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.0
in repository backbone.

commit 8f80fb1fb4ef4843e9edac8a7cb4717e0ac98f5f
Author: Paul Uithol <paul.uithol at gmail.com>
Date:   Tue Mar 22 19:22:46 2011 +0100

    A somewhat smarter approach (more DRY).
---
 backbone.js | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/backbone.js b/backbone.js
index 63b8e43..8671549 100644
--- a/backbone.js
+++ b/backbone.js
@@ -267,8 +267,7 @@
         if (success) success(model, resp);
       };
       options.error = wrapError(options.error, model, options);
-      var request = (this.sync || Backbone.sync).call(this, 'read', this, options);
-      this.promise = _.isFunction( request.promise ) ? request.promise() : request;
+      this.promise = (this.sync || Backbone.sync).call(this, 'read', this, options);
       return this;
     },
 
@@ -286,8 +285,7 @@
       };
       options.error = wrapError(options.error, model, options);
       var method = this.isNew() ? 'create' : 'update';
-      var request = (this.sync || Backbone.sync).call(this, method, this, options);
-	  this.promise = _.isFunction( request.promise ) ? request.promise() : request;
+      this.promise = (this.sync || Backbone.sync).call(this, method, this, options);
       return this;
     },
 
@@ -302,8 +300,7 @@
         if (success) success(model, resp);
       };
       options.error = wrapError(options.error, model, options);
-      var request = (this.sync || Backbone.sync).call(this, 'delete', this, options);
-	  this.promise = _.isFunction( request.promise ) ? request.promise() : request;
+      this.promise = (this.sync || Backbone.sync).call(this, 'delete', this, options);
       return this;
     },
 
@@ -516,8 +513,7 @@
         if (success) success(collection, resp);
       };
       options.error = wrapError(options.error, collection, options);
-      var request = (this.sync || Backbone.sync).call(this, 'read', this, options);
-	  this.promise = _.isFunction( request.promise ) ? request.promise() : request;
+      this.promise = (this.sync || Backbone.sync).call(this, 'read', this, options);
       return this;
     },
 
@@ -538,7 +534,6 @@
         coll.add(nextModel);
         if (success) success(nextModel, resp);
       };
-	  this.promise = model.promise;
       return model.save(null, options);
     },
 
@@ -1017,7 +1012,8 @@
     }
 
     // Make the request.
-    return $.ajax(params);
+    var request = $.ajax(params);
+    return _.isFunction( request.promise ) ? request.promise() : request;
   };
 
   // Helpers

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list