https://github.com/richardscarrott/backbone-ajax-queue
Backbone Ajax Queue updates `Backbone.sync` to allow ajax requests to optionally be queued to help support the development of optimistic, asynchronous user interfaces as described here - http://alexmaccaw.com/posts/async_ui
https://github.com/richardscarrott/backbone-ajax-queue
Last synced: 2 months ago
JSON representation
Backbone Ajax Queue updates `Backbone.sync` to allow ajax requests to optionally be queued to help support the development of optimistic, asynchronous user interfaces as described here - http://alexmaccaw.com/posts/async_ui
- Host: GitHub
- URL: https://github.com/richardscarrott/backbone-ajax-queue
- Owner: richardscarrott
- License: mit
- Created: 2014-11-17T00:28:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-05T11:14:35.000Z (about 10 years ago)
- Last Synced: 2025-03-07T13:47:27.502Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 148 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Backbone Ajax Queue
Backbone Ajax Queue updates `Backbone.sync` to help support the development of [asynchronous user interfaces as described here](http://old.alexmaccaw.com//posts/async_ui).
Whilst there are already a number of code snippets floating around to queue Backbone ajax requests I found they all shared the [same problem](https://github.com/jashkenas/backbone/issues/345):
var model = new Backbone.Model({
url: '/foo'
});// Correctly issues `POST /foo`
model.save({
foo: true
}, { queue: true });// Incorrectly issues `POST /foo` because the model is still considered new until the first POST returns.
model.save({
foo: false
}, { queue: true });// Incorrectly issues no request because the model is still considered new until the first POST returns.
model.destroy({ queue: true });So, even though they are queuing ajax requests, they don't manage the model properly. With Backbone Ajax Queue you instead get:
var model = new Backbone.Model({
url: '/foo'
});// Issues `POST /foo`
model.save({
foo: true
}, { queue: true });// Issues `PUT /foo/{id-from-server}`
model.save({
foo: false
}, { queue: true });// Issues DELETE `/foo/{id-from-server}`
model.destroy({ queue: true });## TODO
- Flesh out README.
- Write tests.
- Create dist task.