Skip to content

v0.4.0

Choose a tag to compare

@emmenko emmenko released this 17 Mar 08:16
· 661 commits to master since this release

Improvements

// assume that we have a product
sphere_client.products.byId('123-abc').fetch()
.then(function(product){
  return sphere_client.products.byId('123-abc').delete(product.version)
})
.then(function(result){
  // a JSON object containing either a result or a SPHERE.IO HTTP error
})
.fail(function(error){
  // either the request failed or was rejected (the response returned an error)
})
  • introduce mixins and batch processing
// let's assume we have a bunch of promises (e.g.: 200)
var allPromises = [p1, p2, p3, ...]

// batch has 2 arguments
// - array_of_promises
// - number_of_parallel_requests (default 50)
sphere_client.mixins.batch(allPromises)
.then(function(result){

})
// You can also subscribe to progress notifications of the promise
.progress(function(progress){
  // progress is an object containing the current progress percentage
  // and the value of the current results (array)
  // {percentage: 20, value: [r1, r2, r3, ...]}

})
.fail(function(error){

})