I have an infobox which is either open or closed depending on the value if isVisible property.
self.infoboxState = ko.computed(function () {
if (!ko.computedContext.isInitial()) {
self.performAdditionalBehaviors();
}
return ko.unwrap(self.isVisible)? 'infobox-open' : 'infobox-closed';
}, this);
When we set the value of isVisible for the second time it would also execute performAdditionalBehaviors()
method. This method contains an observable property isDim
and the infoboxState
becomes dependent on both observables which means any change in the isDim
property will also now call the infoboxState
. I verified that from getDependenciesCount() which is now set to 2.
Issue is that I don't want infoboxState
to get called whenever isDim
is changed. Is there any way to tell the computed to not add a property into it's dependencies list?
Thanks.
self.infoboxState = ko.computed(function () {
if (!ko.computedContext.isInitial()) {
ko.ignoreDependencies(self.performAdditionalBehaviors, self);
}
return ko.unwrap(self.isVisible)? 'infobox-open' : 'infobox-closed';
}, this);