Last active
April 7, 2017 02:06
-
-
Save givanse/9a505c04e139cb14a82ecdc8945e7abf to your computer and use it in GitHub Desktop.
Unrendered computeds
This file contains hidden or 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'; | |
// Two options: | |
// 1. eager load in the init hook | |
// for the initial render, won't re-calc after that. | |
// 2. another computed depending on the unrendered computed | |
// for property updates | |
export default Ember.Controller.extend({ | |
init: function() { | |
this._super(...arguments); | |
// 1. eager load, one off | |
this.get('anotherUnrenderedComputed'); | |
}, | |
text: 'some words', | |
counter1: 0, | |
renderedComputed: Ember.computed('text', function() { | |
return this.counter1++ + ' ' + this.get('text'); | |
}), | |
counter2: 0, | |
unrenderedComputed: Ember.computed('text', function() { | |
return this.counter2++ + ' ' + this.get('text'); | |
}), | |
depsOnUnrenderedComputed: Ember.computed('unrenderedComputed', function() { | |
return this.get('unrenderedComputed'); | |
}), | |
counter3: 0, | |
anotherUnrenderedComputed: Ember.computed('text', function() { | |
console.log('anotherUnrenderedComputed re-calc'); | |
return this.counter3++ + ' ' + this.get('text'); | |
}) | |
}); |
This file contains hidden or 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.10.6", | |
"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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment