Created
February 10, 2016 20:40
-
-
Save Panman82/a10a94caf849da441e70 to your computer and use it in GitHub Desktop.
.set()ing bound prop triggers didReceiveAttrs()
This file contains 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.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
This file contains 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.Component.extend({ | |
init() { | |
this._super( ...arguments ); | |
this.set('attrHookLog', Ember.A()); | |
this.set('_isSettingBaz', false); | |
}, | |
didReceiveAttrs() { | |
if (!this.get('_isSettingBaz')) { | |
this.get('attrHookLog').pushObject( | |
'baz: ' + this.get('baz') | |
); | |
} | |
}, | |
actions: { | |
setBazWithoutFlag() { | |
this.set('baz', 'Amber Twiddle'); | |
}, | |
setBazWithFlag() { | |
this.set('_isSettingBaz', true); | |
this.set('baz', 'Ember 2 Twiddle'); | |
Ember.run.next( this, function(){ | |
this.set('_isSettingBaz', false); | |
}); | |
} | |
} | |
}); |
This file contains 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.5.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment