Batching calls
Features
- Added
batch()
method for sending multiple queries in a single network call.
Info
The batch()
method has a single argument - URI collector function. URI collector function should return an array of URIs which should be executed in a single network call by batch()
.
In order to simplify creation of URIs, URI collector function passed to the batch()
method receives a special instance of Api
, implementing IBatchApi
interface. Almost all functions from Api
are available in IBatchApi
, with the same signatures as in Api
but with one difference - all of them return a string.
Usage
// Let's `api` to be an Api instance
api.batch(batchApi => {
// we should return an array of URIs (path + query portion)
return [
// we can directly write `/USER/count`, but we can use a familiar api instead
batchApi.count('USER'),
// URI to get metadata for TASK object
batchApi.metadata('TASK', ['fields']),
// another URI
batchApi.metadata('PROJ', ['collections'])
]
})