The easiest way to deal with this, I think, is to “raise a flag” just before triggering the event
bypass_notifier = true -- raise the flag
set_dropdown_value() -- perform some function that will invoke the notifier method
bypass_notifier = false -- lower the flag
Then, in the notifier method you can check the flag’s condition
notifier = function(e)
if not bypass_notifier then
-- add code to handle the event
end
end
I believe that notifier feedback is something which cannot easily be avoided: As long as you are listening for something whose value you modify, you risk getting caught in one of these loops.
IMHO, it’s not something which could / should be solved on the API level - it’s up to us script authors to avoid these endless loops
That said, I think it’s awesome that the Renoise API has built-in feedback detection - after all, it is quite easy to make such a script by accident.
You may change the value once in the script, but one of the pitfalls here is that the change is causing your object function to also make a change in the pattern, instrument or whatever and if you happen to have an observable attached to that object in Renoise, it would then on its turn fire the observable function which in turn might have a reference to change the value in your GUI object (that you already changed once in your other routine)… and that is how the infinite circle is continuing without you knowing it.
Danoise his suggestion to indeed add a cross-reference parameter check to prevent different routines battling with eachother to change the parameter is the best way to go.
vb:popup
id = "popup_patches",
notifier = function(new_index)
pcall(change_me_already, 5)
end
}
function change_me_already(val)
vb.views.popup_patches.value = val
end