COMMUNITY

Haxe queue for running async tasks sequentially in js

async
haxe-js

(Дмитрий Маликов) #1

i have some third part rest api libary which make http requests asynchroniusly in oldscool callbacks style

RestApi.callMethod('products.list', {some_param_active: 1}, function (result) { 
  console.log(result.data()); // here 10 products

result.data().forEach(function (item) {
 // if i call some another rest api method here for each item - this will produces  10 async requests %)
});

  if (result.more()) {    
    result.next(); // this will fetch next 10 products and make more request instantly!
  }
 })

i need to limit for 1 task
which libs exists for limit async task to 1 instance?


(Allan Dowdeswell) #2

Perhaps using Callback or Future from the Tink library would do the trick?