Call Batching

You can group several remote calls together using a batch. This saves on round trips to the server so there is much less latency involved.

A batch is started with dwr.engine.beginBatch() and ended with dwr.engine.endBatch(). When endBatch() is called, we are finished grouping a set of remote calls together, so DWR executes them in a single round trip to the server.

DWR takes care of ensuring that all the callbacks are called so you can turn batching on and off transparently. Just don't forget to call endBatch() or all your remote calls will be queued for ever.

Caveats

Clearly there are some side effects of batching a number of calls together. It would be impossible to be synchronous and batched at the same time for example.

All the call object options like hooks, timeouts and errorHandlers are done at a batch level rather than a call level. So if in a single batch you have 2 calls with different timeout values then all but the last will be ignored.