sendNotification loopback?


I am only getting started, so perhaps a stupid question, but when using listeners and sendNotification, should I take care to avoid loopbacks, or does Juce internally take care of that?
I learn from Martin Robinson’s book.
There is an example, where you have a label (setEditable) and a slider.
Both have addListener
When you move slider, the sliderValueChanged is to write slider’s value into label’s text.
When you write number into label’s text, labelTextChanged set the slider’s value to that number.

To me it seems, that when I move the slider, it should change the label, which should in turn change the slider, which should in turn change the text (to same values, but whatever).

I tried to make a different code - two sliders and:
void MainContentComponent::sliderValueChanged(Slider* slider)
if (&slider1 == slider) slider2.setValue(slider1.getValue() + 0.1, sendNotification);
if (&slider2 == slider) slider1.setValue(slider2.getValue() + 0.1, sendNotification);
and indeed when i change value of either slider, both goes to maximum… so it seems like my assumption is correct and those notifications can loopback and cause trouble?

Please, could somebody explain this to me?


A lot of the classes will avoid sending notifications unless the value changes, e.g. calling setValue on a Slider will do nothing unless it’s different, so that avoids a lot of loops. But there’s nothing inherently built into the notification system itself that could stop loopbacks, and I don’t even think that’d be possible (how could it know whether you’re doing it intentionally?)


Thanks for the answer.
I get it now.