0

I have the following code that I am looking to simplify:

var MM = Microsoft.Maps;
MM.loadModule("MM.Clustering", function () { 
    MM.loadModule("HtmlPushpinLayerModule", function () { 
        // Do actual work
    });
});

Is it possible to combine these into something like (pseudocode):

MM.loadModule("MM.Clustering") && MM.loadModule("HtmlPushpinLayerModule"), function() {
    // Do actual work
}); 
AngryHacker
  • 59,598
  • 102
  • 325
  • 594

1 Answers1

1

You can use Promises and use Promise#all for waiting for the callbacks.

You can see something like this in this question: Microsoft bing maps api and loading modules issue

Ciro Spaciari
  • 630
  • 5
  • 10