Skip to content

Instantly share code, notes, and snippets.

@wojciechb
Last active November 13, 2017 14:44
Show Gist options
  • Save wojciechb/0013158a9b79d3c9c9ec3020d3406b73 to your computer and use it in GitHub Desktop.
Save wojciechb/0013158a9b79d3c9c9ec3020d3406b73 to your computer and use it in GitHub Desktop.
render
import Ember from 'ember';
export default Ember.Component.extend({
willRender() {
console.log('child will A');
this._super(...arguments);
console.log('child will B');
//
//alert('my-component-child willRender');
},
didRender() {
console.log('child did A');
this._super(...arguments);
console.log('child did B');
// alert('my-component-child didRender');
},
name: null,
actions: {
updateName() {
this.set('name', Math.random());
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
willRender() {
console.log('parent will A');
this._super(...arguments);
console.log('parent will B');
//alert('my-component-parent willRender');
},
didRender() {
console.log('parent did A');
this._super(...arguments);
console.log('parent did B');
//a//lert('my-component-parent didRender');
},
actions: {
updateName() {
this.set('name', Math.random());
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
willRender() {
console.log('my will A')
this._super(...arguments);
console.log('my will B')
// alert('my-component willRender');
},
didRender() {
console.log('my did A')
this._super(...arguments);
console.log('my did B')
//alert('my-component didRender');
},
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
updateRandom() {
this.set('random', Math.random());
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<button {{action 'updateRandom'}}>update</button>
{{my-component-parent random=random}}
{{outlet}}
<br>
<br>
my-component-child {{random}} {{name}} <button {{action 'updateName'}}>update child</button>
{{yield}}
my-component-parent {{random}} {{name}} <button {{action 'updateName'}}>update parent</button>
{{my-component random=random}}
my-component {{random}}
{{my-component-child random=random}}
{
"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-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment