Created
July 6, 2017 07:50
-
-
Save dan-ste/5c8343f639338b52136ea08e55e0c400 to your computer and use it in GitHub Desktop.
Production ready
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default TutorialComponent.extend({ | |
result: null, | |
isFindingStores: false, | |
actions: { | |
findStores() { | |
if (this.isFindingStores) { return; } | |
let geolocation = this.get('geolocation'); | |
let store = this.get('store'); | |
this.set('isFindingStores', true); | |
geolocation.getCoords() | |
.then(coords => store.getNearbyStores(coords)) | |
.then(result => { | |
if (this.isDestroyed) { return; } | |
this.set('result', result); | |
}) | |
.finally(() => { // ++ | |
if (this.isDestroyed) { return; } // ++ | |
this.set('isFindingStores', false); // ++ | |
}); | |
} | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment