Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Last active August 29, 2015 14:26
Show Gist options
  • Save jgwhite/5ee4df96e7dea8232abf to your computer and use it in GitHub Desktop.
Save jgwhite/5ee4df96e7dea8232abf to your computer and use it in GitHub Desktop.
CP setter without return value misbehaves
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Controller.extend({
goldenRatioWidth: computed('height', {
get(key) {
return this.get('height') * 1.618;
},
set(_, value) {
this.set('height', value / 1.618);
// Try commenting out the return statement...
return value;
}
}),
height: 100
});
<p>Width: {{input value=goldenRatioWidth}}</p>
<p>Height: {{input value=height}}</p>
{
"version": "0.4.0",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.5/ember.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.5/ember-data.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment