Skip to content

Instantly share code, notes, and snippets.

@tzellman
Created April 27, 2017 21:55
Show Gist options
  • Save tzellman/3a1a9e83d6e14b0f7a9c10e6ea437a7e to your computer and use it in GitHub Desktop.
Save tzellman/3a1a9e83d6e14b0f7a9c10e6ea437a7e to your computer and use it in GitHub Desktop.
Recursive Ember Concurrency Example
import Ember from 'ember';
import {task, timeout} from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
count: 0,
recursiveTask: task(function*(){
yield timeout(1000);
this.incrementProperty("count", 1);
this.get("recursiveTask").perform();
}).restartable(),
init(){
this.get("recursiveTask").perform();
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
The current count is: {{count}}
<br>
<br>
{
"version": "0.12.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.12.1",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-concurrency": "0.8.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment