Asynchronously wait for a function to be called
问题 I'm using the bing-maps JS control and API in WebKit (Android) and WKWebView (iOS). var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {}); // Binding the event Microsoft.Maps.Events.addHandler(map, 'viewchangeend', function () { console.log('mapViewchangeend'); }); Later in the code I have a call to map.setView. Because this method is asynchronous I need to wait for the event handler to call the function above. function SetMapViewLocations(pointsToView) { try { if