# Haxe queue for running async tasks sequentially in js

**URL:** https://community.haxe.org/t/haxe-queue-for-running-async-tasks-sequentially-in-js/1019
**Category:** Haxe
**Tags:** haxe-js, async
**Created:** [September 1, 2018, 11:29am UTC](https://community.haxe.org/t/haxe-queue-for-running-async-tasks-sequentially-in-js/1019 "2018-09-01T11:29:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rivetweb](https://community.haxe.org/user_avatar/community.haxe.org/rivetweb/32/1338_2.png) [@rivetweb](https://community.haxe.org/u/rivetweb)
#### Post date: [September 1, 2018, 11:29am UTC](https://community.haxe.org/t/haxe-queue-for-running-async-tasks-sequentially-in-js/1019/1 "2018-09-01T11:29:11Z")

</div>

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

```haxe
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?

---

<div class="post-metadata">

### Author: ![Confidant](https://community.haxe.org/user_avatar/community.haxe.org/confidant/32/63_2.png) [@Confidant](https://community.haxe.org/u/Confidant)
#### Post date: [September 1, 2018, 7:26pm UTC](https://community.haxe.org/t/haxe-queue-for-running-async-tasks-sequentially-in-js/1019/2 "2018-09-01T19:26:47Z")

</div>

Perhaps using [Callback](https://haxetink.github.io/tink_core/#/types/callback) or [Future](https://haxetink.github.io/tink_core/#/types/future) from the [Tink](https://github.com/haxetink/tink_core) library would do the trick?
