Last active
December 5, 2017 19:08
-
-
Save vitch/dbc65a4222fb9c4dc49319126209dc62 to your computer and use it in GitHub Desktop.
Concurrency meets Evented
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 Thing from 'twiddle/thing'; | |
import { task } from 'ember-concurrency'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
thing: Ember.computed(() => Thing.create()), | |
_loadData: task(function* () { | |
let api = this.get('thing'); | |
yield api.stuff() | |
.on('dataUpdate', () => { | |
console.log('HI'); | |
}); | |
}).drop(), | |
actions: { | |
loadData() { | |
this.get('_loadData').perform(); | |
}, | |
} | |
}); |
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'; | |
export default Ember.Object.extend(Ember.Evented, { | |
stuff() { | |
console.log('stuff'); | |
Ember.run.later(() => { | |
this.trigger('dataUpdate'); | |
}, 2000); | |
return this; | |
}, | |
}); |
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.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.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-concurrency": "0.8.12" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment