Skip to content

Instantly share code, notes, and snippets.

@noslouch
Created June 21, 2016 03:50
Show Gist options
  • Save noslouch/8d87655154527d9fe06172bbe3557818 to your computer and use it in GitHub Desktop.
Save noslouch/8d87655154527d9fe06172bbe3557818 to your computer and use it in GitHub Desktop.
complex computed props
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
someVal: 'foo',
oneWayComputed: Ember.computed.oneWay('someVal'),
complexComputed: Ember.computed('someVal', {
get() {
return this.get('someVal');
},
set(k,v) { return v }
})
});
<h1>Complex Computed Props</h1>
<h3> some value other props depend upon</h3>
<em>change this and watch the others update</em><br>
<code>someVal</code>: {{input value=someVal}}<br>
<br>
<h3>once this is set, it will not update with its dependent key</h3>
<em>change this and update someVal. this will not update.</em><br>
<code>oneWayComputed</code>: {{input value=oneWayComputed}}<br>
<br>
<h3>can set this and it will update when its dependent key updates</h3>
<em>change this, and then change someVal. watch this reset to the value of someVal.</em><br>
<code>complexComputed</code>: {{input value=complexComputed}}<br>
<br>
<br>
{
"version": "0.9.3",
"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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment