Ember.js Starter Kit
Based on latest version (as of today) of the official Ember.js starter kit:
https://github.com/emberjs/starter-kit
Links to latest full-size versions of Handlebars, Ember, and Ember-Data.
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.7.0/ember.js"></script>
JavaScript
var object = Ember.Object.extend({
aPropertyThatChangesManyTimes : null,
aPropertyWichReturnSameValue : function(){
console.log('someOne Calls aPropertyWichReturnSameValue'); // Consume property
return 1;
}.property('aPropertyThatChangesManyTimes').cacheable(true),
aPropertyThatDependsOnThePropertyWichReturnSameValue : function(){
console.log('someOne Calls aPropertyThatDependsOnThePropertyWichReturnSameValue. NOT SHOULD BE FIRED IF dependant data not changed !');
return this.get('aPropertyWichReturnSameValue'); // Consume property
}.property('aPropertyWichReturnSameValue').cacheable(true),
aObserverThatDependsOnThePropertyWichReturnSameValue : function(){
console.log('someOne Calls aObserverThatDependsOnThePropertyWichReturnSameValue. NOT SHOULD BE FIRED IF dependant data not changed !');
return this.get('aPropertyWichReturnSameValue'); // Consume property
}.observes('aPropertyWichReturnSameValue')
}).create({aPropertyThatChangesManyTimes:-1});
Ember.run(function(){
var i;
var N = 2;
console.log('\n\nTest Started! ( Ember version: '+Ember.VERSION+'\n');
console.log('test_1: Change source dependency value and check if ember trigger observer and computed of nested dependency property ONCE, because it should cache and not propagate changes of nested computed properties');
for(i=0;i<N;i++) {
console.log('test_1 - Set aPropertyThatChangesManyTimes random value and consume nested computed property');
object.set('aPropertyThatChangesManyTimes',i);
object.get('aPropertyThatDependsOnThePropertyWichReturnSameValue');
}
console.log('\n\n');
console.log('test_2: call "set" with CONSTANT SCALAR value to a property, and see if ember propagate changes like test1');
for(i=0;i<N;i++) {
console.log('test_2 - Set aPropertyThatChangesManyTimes CONSTANT...