Last active
April 17, 2016 18:59
-
-
Save hakilebara/48dead207a2cd3e22be5adeeb18e4303 to your computer and use it in GitHub Desktop.
ember-concurrency__001
This file contains hidden or 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'; | |
import { task, timeout } from 'ember-concurrency'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
status: "Waiting to start", | |
parentTask: task(function * () { | |
this.set('status', "1. Parent: one moment..."); | |
yield timeout(1000); | |
let value = yield this.get('childTask').perform(); | |
this.set('status', `5. Parent: child says "${value}"`); | |
yield timeout(1000); | |
this.set('status', "6. Done!"); | |
}).restartable(), | |
childTask: task(function * () { | |
this.set('status', "2. Child: one moment..."); | |
yield timeout(1000); | |
let value = yield this.get('grandchildTask').perform(); | |
this.set('status', `4. Child: grandchild says "${value}"`); | |
yield timeout(1000); | |
return "What's up"; | |
}), | |
grandchildTask: task(function * () { | |
this.set('status', "3. Grandchild: one moment..."); | |
yield timeout(1000); | |
return "Hello"; | |
}), | |
actions: { | |
cancel(task) { | |
task.cancel(); | |
} | |
} | |
}); |
This file contains hidden or 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
{ | |
"version": "0.8.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.5.0", | |
"ember-data": "2.5.1", | |
"ember-template-compiler": "2.5.0", | |
"babel-polyfill":"https://cdn.rawgit.com/nicksrandall/babel-polyfill/master/browser-polyfill.js" | |
}, | |
"addons": { | |
"ember-concurrency": "0.6.0" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment