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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
for(var i = 0; i<=5; i++) { | |
setTimeout(function timer() { | |
console.log(i); | |
}, i*1000); | |
} |
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, | |
findStores: task(function * () { | |
let geolocation = this.get('geolocation'); | |
let store = this.get('store'); | |
try() { | |
let coords = yield geolocation.getCoords(); | |
let result = yield store.getNearbyStores(coords); | |
this.set('result', result); |
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
import { task } from 'ember-concurrency'; | |
export default TutorialComponent.extend({ | |
result: null, | |
findStores: task(function * () { | |
let geolocation = this.get('geolocation'); | |
let store = this.get('store'); | |
let coords = yield geolocation.getCoords(); |
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, // Add a Loading Spinner | |
actions: { | |
findStores() { | |
if (this.isFindingStores) { return; } // Preventing Concurrency | |
let geolocation = this.get('geolocation'); | |
let store = this.get('store'); |
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 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, | |
actions: { | |
findStores() { | |
let geolocation = this.get('geolocation'); | |
let store = this.get('store'); | |
geolocation.getCoords() | |
.then(coords => store.getNearbyStores(coords)) | |
.then(result => { |
NewerOlder