View controllers.application.js
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' | |
}); |
View gist:1f34ecd204bfeef220f0f8f8b238dc67
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); | |
} |
View gist:47c1eda47ef95508a6e8cb06a4c3f811
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); |
View prevent-concurrency.js
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(); |
View production-ready.js
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'); |
View production-ready.js
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'); |
View bare-minimum.js
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