Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync() should return a promise #23

Closed
andornaut opened this issue Dec 16, 2012 · 2 comments · Fixed by #24
Closed

sync() should return a promise #23

andornaut opened this issue Dec 16, 2012 · 2 comments · Fixed by #24

Comments

@andornaut
Copy link
Contributor

Backbone.indexdb.sync should maintain the same interface as Backbone.sync by returning a Deferred Promise object.

Backbone's sync() returns the xhr object from JQuery's ajax():

Backbone.sync = function(method, model, options) {
    //...

    var xhr = Backbone.ajax(_.extend(params, options));
    model.trigger('request', model, xhr, options);
    return xhr;
}
Backbone.ajax = function() {
    return Backbone.$.ajax.apply(Backbone.$, arguments);
};

This would also provide a workaround for people looking for synchronous behaviour such as in this other ticket #19.

Unfortunately Zepto doesn't provide an implementation of Deferred, but hopefully it'll be added soon:

madrobby/zepto#353

@julien51
Copy link
Member

Please submit a patch.
On Dec 16, 2012 1:06 PM, "andornaut" notifications@github.com wrote:

Backbone.indexdb.sync should maintain the same interface as Backbone.syncby returning a Deferred Promise object.

Backbone's sync() returns the xhr object from JQuery's ajax():

Backbone.sync = function(method, model, options) {
//...

var xhr = Backbone.ajax(_.extend(params, options));
model.trigger('request', model, xhr, options);
return xhr;

}

Backbone.ajax = function() {
return Backbone.$.ajax.apply(Backbone.$, arguments);
};

This would also provide a workaround for people looking for synchronous
behaviour such as in this other ticket #19#19
.

Unfortunately Zepto doesn't provide an implementation of Deferred, but
hopefully it'll be added soon:

madrobby/zepto#353 madrobby/zepto#353


Reply to this email directly or view it on GitHubhttps://github.com//issues/23.

@andornaut
Copy link
Contributor Author

Done #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants