lime icon indicating copy to clipboard operation
lime copied to clipboard

Add standard convenience functions for creating Promises to resolve groups of Futures.

Open EliteMasterEric opened this issue 1 year ago • 8 comments
trafficstars

Several convenience functions which mostly mimic promise handling functionality from JavaScript. Definitely standard enough to be part of the base library.

  • Promises.all() resolves an array of Futures, completing when all of the Promises are fulfilled or any of the Promises are rejected.
  • Promises.allSettled() resolves an array of Futures, completing when all of the Promises are fulfilled or rejected.
  • Promises.any() resolves an array of Futures, completing when any of the Promises is fulfilled or all of the Promises are rejected.
  • Promises.race() resolves an array of Futures, completing when any of the Promises is fulfilled or rejected.

Good example use cases include calling lime.utils.Assets.loadImage() for each of an Array of images; you now have multiple promises, and want to wait for all of them to resolve before continuing.

EliteMasterEric avatar Sep 29 '24 14:09 EliteMasterEric