Skip to content

Instantly share code, notes, and snippets.

@dan-ste
Created July 6, 2017 07:50
Show Gist options
  • Save dan-ste/5c8343f639338b52136ea08e55e0c400 to your computer and use it in GitHub Desktop.
Save dan-ste/5c8343f639338b52136ea08e55e0c400 to your computer and use it in GitHub Desktop.
Production ready
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