Last active
November 10, 2015 19:04
-
-
Save joebartels/acb8cbf30c7dbbd0a4b2 to your computer and use it in GitHub Desktop.
observing attrs.value
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', | |
foo: 1, | |
bar: 100, | |
actions: { | |
tap: function() { | |
this.decrementProperty('foo'); | |
} | |
} | |
}); |
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'; | |
const { | |
observer, | |
Logger | |
} = Ember; | |
export default Ember.Component.extend({ | |
obs1: 0, | |
obs2: 0, | |
barObs1: observer('bar', function() { | |
Logger.log('bar observer fired!'); | |
this.incremementProperty('obs1'); | |
}), | |
barObs2: observer('attrs.bar', function() { | |
Logger.log('attrs.bar observer fired!'); | |
this.incrementProperty('obs2'); | |
}), | |
didRender: function(attrs) { | |
this._super(); | |
Logger.log(attrs); | |
Logger.log(`foo: ${this.getAttr('foo')}`); | |
Logger.log(`bar: ${this.getAttr('bar')}`); | |
} | |
}); |
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.4.16", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "1.13.10", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js", | |
"ember-template-compiler": "1.13.10" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment