dimanche 30 décembre 2018

Run Ember.run.later from action triggered

I am having problem with action handling in Ember controller. I want to run some function continiously after edit button is clicked in hbs. I have tried it like this in action.

openEditWindow() {
  this.set('someChangingValue', true);
},

Here is the function that reacts to action someChangingValue change.

someChangingValue: false,    

someTestFunction: observer('someChangingValue', function(){
 var test = this.get('someChangingValue');

if(test === true){
  Ember.run.later((function() {
    this.functionThatIsRunningEachTwoSeconds();
  }), 2000);   
} else {
  console.log('this should not do anything');
}
}),

But this runs functionThatIsRunningEachTwoSeconds only once. Also tried the same functionality with changing someChangingValue to false if true and otherwise, that put me in infinite loop of observing property.

Thanks!




Aucun commentaire:

Enregistrer un commentaire