gokatz
11/17/2016 - 1:29 PM

computed property triggered once when setting property chances chained

computed property triggered once when setting property chances chained

{
  "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.9.0",
    "ember-data": "1.13.15",
    "ember-template-compiler": "2.9.0",
    "ember-testing": "2.9.0"
  },
  "addons": {}
}
<h1>Welcome to {{appName}}</h1>
<br>
{{testingLoad}}
<br>
<button {{action 'continuousSet'}}>SET</button>
{{outlet}}
<br>
<br>
import Ember from 'ember';

export default Ember.Controller.extend({
  appName: 'Ember Twiddle',
  isLoading: false,
  
  testingLoad: Ember.computed('isLoading', function() {
  	console.log(this.get('isLoading'));
  }),
  
  javvuMittai() {
  	for(let i=0; i<99999999; i++) {
    	//do nothing
    }
  },
  
  actions: {
  	continuousSet() {
      for(let i=0; i<3; i++) {
        console.log('---start---');
				this.set('isLoading', '1');
        this.javvuMittai();
      	this.set('isLoading', '2'); 
        this.javvuMittai();
        console.log('---end---');
      }
    }
  }
});