maccman/spine — pull request #336 by jcarlson (2012-06-20 16:22:24+00:00)
Title: Support parallel AJAX requests

In regards to https://groups.google.com/forum/#!topic/spinejs/UoOcX6gcLvc

This patch changes the internal behavior of the Spine.Ajax module. All Ajax operations are now sent through Spine.Ajax.queue (not just the singleton calls), and the queue determines if the request may be dispatched immediately or must be queued.

The changes are 100% backwards compatible; requests on the collection, e.g., Model.find() and Model.fetch() are still dispatched immediately, unless PUT, POST or DELETE requests are pending. This "unless" clause is new, however. Previously, a collection GET method would have been sent immediately, even if a DELETE operation was still pending on the collection.

To preserve backwards compatibility, operations on a model instance are still serialized unless parallel support is explicitly set in the params.

To invoke an Ajax request with support for parallelization, simply add the argument to the methods' params hash:

``` ruby
# parallel on the collection is enabled by default
# instance methods, such as model.save() will not be parallel unless explicitly enabled
Model.fetch() # will be parallel
#...
model = Model.find(123)
model.foo = "something else"
model.save({parallel: true}) # will be parallel
```

In general, this should speed up some Ajax scenarios.