0

I'd like to implement a search in progress indicator. It would be nice to use the radarPromise status as the progress indicator trigger. Apparently, you cannot access the status property of a native promise in javascript. Any tricks or alternatives?

   $('#calculate-route').off('submit').on('submit', function(event){
        event.preventDefault();
        console.log('submit');
        search.query = document.getElementById("search").value;

    var routeSearch = new MyGlobal.findRoutes({
        originPlaceId: search.placeInputIds.originPlaceId,
        destinationPlaceId: search.placeInputIds.destinationPlaceId,
        directionsService: search.directionsService,
        directionsDisplay: search.directionsDisplay,
        travel_mode: search.travel_mode
    })
    .then(function(response){
        var routeBoxes = new MyGlobal.routeBoxes({
            radius: parseFloat(document.getElementById("radius").value),
            path: response.routes[0].overview_path,
            map: search.map
        });
        routeBoxes.draw();
        var radarSearch = new MyGlobal.radarSearch(search.placesService);
        var radarPromise = MyGlobal.radarSearchByBoxes(routeBoxes.bounds, search.query, radarSearch)
    .then(function(places){
        alert("done");
    });

    });

});
malexanders
  • 3,203
  • 5
  • 26
  • 46
  • According to MDN that's "by design". I've no idea why. Very curious of the answer. – Rudie May 08 '16 at 20:16
  • I just came from MDN and read the same thing. I'm also curious! – malexanders May 08 '16 at 20:18
  • 1
    I don't get what you want. Promises don't have a progress, they are just either settled or not. Why would you want to access the status? Isn't it as simple as `trigger(0); radarPromise.then(()=>trigger(100), (err)=>trigger(-1))`? – Bergi May 08 '16 at 22:47
  • I want to use the promise status I.E pending or settled as the trigger for a search in progress indicator. While the promise is pending, the search is in progress, once it is settled/resolved, the search is complete. – malexanders May 09 '16 at 02:56
  • @matthewalexander: Yes, just use `then` to trigger the indicator. You don't need access to some "promise status". – Bergi May 09 '16 at 13:52

0 Answers0