Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Use an object of promises in Promise.all() #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lukefx
Copy link

@lukefx lukefx commented Dec 16, 2014

So basically the idea is the same as Dojo where we can pass an object to Promise.all() and the results are paired with their keys. With this way I can identify where the result came from.

Instead of an array we use and object

Promise.all({
  tableA: Promise.when(queryTask1.execute(query)),
  tableB: Promise.when(queryTask2.execute(query))
}).then(onTaskResult).otherwise(onTaskFault);

Then we can use the object keys to identify the results

private function onTaskResult(results:Object):void {
  for (var key:String in results) {
    ...
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant