Skip to content

Instantly share code, notes, and snippets.

@scottmessinger
Last active October 6, 2016 22:36
Show Gist options
  • Save scottmessinger/ed778b37d75d558108599af80a80f5a3 to your computer and use it in GitHub Desktop.
Save scottmessinger/ed778b37d75d558108599af80a80f5a3 to your computer and use it in GitHub Desktop.
Rerender entire tree
import Ember from 'ember';
export default Ember.Component.extend({
didReceiveAttrs(){
this._super(...arguments)
console.log('didReceiveAttrs', 'a-child')
}
});
import Ember from 'ember';
export default Ember.Component.extend({
aPropertyInsideTheParent: "a",
didReceiveAttrs(){
this._super(...arguments)
console.log('didReceiveAttrs', 'the-parent')
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
data: {val: 1},
actions: {
increment(){
Ember.set(this, "data", {
val: Ember.get(this, "data.val") + 1
})
}
}
});
<button {{action "increment"}}>Inc</button>
{{the-parent data=data}}
<p> Open the console to see `a-child` component rerendering even though nothing passed to them changed.</p>
a-child component: {{val}}
{{data.val}}
{{a-child val=aPropertyInsideTheParent}}
{{a-child val=aPropertyInsideTheParent}}
{{a-child val=aPropertyInsideTheParent}}
{{a-child val=aPropertyInsideTheParent}}
{
"version": "0.10.5",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "beta",
"ember-data": "2.8.0",
"ember-template-compiler": "beta",
"ember-testing": "beta"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment