Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Last active September 5, 2018 19:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpadilla/c3d581cc8a4396638723b77ce382706d to your computer and use it in GitHub Desktop.
Save jpadilla/c3d581cc8a4396638723b77ce382706d to your computer and use it in GitHub Desktop.
ember-concurrency-demo
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
export default Ember.Component.extend({
task: Ember.computed('query', function() {
return this.get('fetchData').perform(this.query);
}),
fetchData: task(function*(query) {
yield timeout(3000);
return query;
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
{{#my-component query="hello" as |task|}}
<p>state: {{task.state}}</p>
<p>value: {{if task.value task.value "-"}}</p>
{{/my-component}}
{
"version": "0.13.1",
"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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3",
"ember-concurrency": "0.8.17"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment