[#35,all][m]: crude error catching for backends based on timeouts (best we can do with JSONP) - fixes #35.

* Show errors in UI
* required some extensive refactoring to use done/fail on promise rather than then
This commit is contained in:
Rufus Pollock
2012-02-10 03:14:52 +00:00
parent d17fa4a169
commit 21173b6acf
4 changed files with 78 additions and 24 deletions

View File

@@ -35,13 +35,12 @@ this.recline.Model = this.recline.Model || {};
// this does not fit very well with Backbone setup. Backbone really expects you to know the ids of objects your are fetching (which you do in classic RESTful ajax-y world). But this paradigm does not fill well with data set up we have here.
// This also illustrates the limitations of separating the Dataset and the Backend
query: function(queryObj) {
this.queryState = queryObj || this.defaultQuery;
this.queryState = _.extend({size: 100, offset: 0}, this.queryState);
var self = this;
var backend = my.backends[this.backendConfig.type];
this.queryState = queryObj || this.defaultQuery;
this.queryState = _.extend({size: 100, offset: 0}, this.queryState);
var dfd = $.Deferred();
backend.query(this, this.queryState).then(function(rows) {
backend.query(this, this.queryState).done(function(rows) {
var docs = _.map(rows, function(row) {
var _doc = new my.Document(row);
_doc.backendConfig = self.backendConfig;
@@ -50,6 +49,9 @@ this.recline.Model = this.recline.Model || {};
});
self.currentDocuments.reset(docs);
dfd.resolve(self.currentDocuments);
})
.fail(function(arguments) {
dfd.reject(arguments);
});
return dfd.promise();
},