How to Determine a JavaScript Promise’s Status

Promises have changed the landscape of JavaScript. Many old APIs have been reincarnated to use Promises (XHR to fetch, Battery API), while new APIs trend toward Promises. Developers can use async/await to handle promises, or then/catch/finally with callbacks, but what Promises don’t tell you is their status. Wouldn’t it be great if the Promise.prototype provided developers a status property to know whether a promise is rejected, resolved, or just done? My research led me to this gist which I found quite clever. I took some time to modify a bit of code and add comments. The following solution provides helper methods for determining a Promise’s status: // Uses setTimeout with... more →
Posted in: JavaScript

Google Maps’ location sharing will now share your phone’s battery status, too – TechCrunch

TechCrunch Google Maps' location sharing will now share your phone's battery status, tooTechCrunchIf you try to ping someone's location and their phone is dead, there's not much an app can do. Most location-sharing apps will just sit there and spin while they wait for some sort of response, leaving you to worry about all the reasons their phone …Google Maps Updates: What's New on the App?Heavy.comGoogle Maps location sharing now also shares your phone's battery lifeThe VergeGoogle kills off the flat earth: Maps app now zooms out to show a 3D globeDaily MailVentureBeat –Engadget –News18 –Android Policeall 186 news articles » map... more →
Posted in: Interactive Maps