Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
sum: Ember.computed("a", "b", {
get() {
return this.get("a") + this.get("b");
}
}),
subtotal: Ember.computed.readOnly("sum")
});
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
init() {
this._super(...arguments);
},
appName: 'Ember Twiddle',
delayed: Ember.computed(() => {
let promise = new Ember.RSVP.Promise(resolve => setTimeout(() => resolve({a: 40, b: 50}), 1000));
return DS.PromiseObject.create({ promise});
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{#my-component a=delayed.a b=delayed.b as |data|}}
{{sub-component subtotal=data.subtotal}}
{{/my-component}}
<h3>my-component</h3>
{{yield (hash sum=sum subtotal=subtotal)}}
<h3>sub-component</h3>
{{yield}}
{{subtotal}}
{
"version": "0.10.6",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://s3.amazonaws.com/builds.emberjs.com/release/ember.prod.js",
"ember-data": "2.10.0",
"ember-template-compiler": "release",
"ember-testing": "release"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment