knockout.js - Cyclic dependency using Knockout subscribe -


is there possible fix below code face cyclic dependency using knockout.js subscribe.

this.observable1.subscribe(function(value){ self.observable2("somevalue"); });  this.observable2.subscribe(function(value){ self.observable1("somevalue"); }); 

where "self" alias "this" , observable1 linked combo box, , observable2 linked date picker.

kindly suggest

as @origineil said, need re-think solution.

but if want keep current solution, use flag break cycle.

var isinnerupdate = false;  this.observable1.subscribe(function(value){   if (isinnerupdate) {     isinnerupdate = false;   } else {     isinnerupdate = true;     self.observable2("somevalue");   } });  this.observable2.subscribe(function(value){     if (isinnerupdate) {     isinnerupdate = false;   } else {     isinnerupdate = true;     self.observable1("somevalue");   } }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -