Running code after multiple promises have resolved

Hi All,

I have a situation where I have multiple data sources to load and I have some JS code that has to be run after all the data sources have loaded (ie. All the DS promises have resolved)

What promise implementation does Cesium use? Is it using browser built-in Promise APIs or an external promise library?

I don’t want to have to use nested then() callback spaghetti to achieve this if it can be avoided. Normally I would look for something like Promise.all() (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) to do this, but I don’t know what promise implementation Cesium is actually using so that I can reliably do this cross-browser (IE11 does not have built-in Promise API support)

  • Jackie

Looks like Cesium is using an older version of When.js - apparently version 1.7.1. It lives in the Cesium repo under /Source/ThirdParty/.

While it’s true that Cesium is using an older version of when, You can use whatever promise library you want in your own apps and our promises will be compatible. For example bluebird or native Promises should work without any issues. They all implement the Promise A+ specification. If you are using Cesium’s implementation, then Cesium.when.all() will work the same was as Promise.all.

As an aside, we’d love to upgrade when or switch to something like bluebird, but there are some breaking changes that have a big affect on imagery/terrain loading when it comes to already-resolved promises.

Yep, Cesium.when was what I was looking for. Thanks.

  • Jackie