Skip to content

Instantly share code, notes, and snippets.

@pixelhandler
Forked from btecu/components.x-child.js
Last active July 15, 2016 19:09
Show Gist options
  • Select an option

  • Save pixelhandler/3f92337ff932302dc26556a93698029d to your computer and use it in GitHub Desktop.

Select an option

Save pixelhandler/3f92337ff932302dc26556a93698029d to your computer and use it in GitHub Desktop.
Component Lifecycle Mut
import Ember from 'ember';
export default Ember.Component.extend({
vDidReceiveAttrs: null,
didReceiveAttrs() {
this._super(...arguments);
console.log('\ndidReceiveAttrs', this.get('vDidReceiveAttrs'));
this.set('vDidReceiveAttrs', 99);
console.log('\ndidReceiveAttrs', this.get('vDidReceiveAttrs'));
}
});
import Ember from 'ember';
const {
Controller,
observer
} = Ember;
export default Controller.extend({
appName: 'Ember Twiddle',
vDidReceiveAttrs: 2,
oDidReceiveAttrs: observer('vDidReceiveAttrs', function() {
console.log('didReceiveAttrs changed value', this.get('vDidReceiveAttrs'));
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{x-child vDidReceiveAttrs=vDidReceiveAttrs}}
vDidReceiveAttrs: {{vDidReceiveAttrs}}
{
"version": "0.10.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.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment