Document Api, Notifiers Don'T Trigger For List When Assisigned By

I think this is a bug here and the notifier should be triggered even when the value was changed using indexed access to the list. Only tested for the strings list and small TestPad code below:

 local rd = renoise.Document.create()  
 local strings_notifier = function()  
 print("--- notifier triggered")  
 for i = 1, #rd.list do  
 rd:add("list", {"string1", "string2", "string3"})  
 -- works   
 -- works not  
 rd.list[2].value = "slipped through"  
 print("--- no notifier triggered")  
 for i = 1, #rd.list do  

See Renoise.Document.API.lua #222 please. This is intended behavior.

Hmm, wouldn’t it make more sense to trigger too in that case? If i setup a watchguard for a list i do expect it to notify me if something in that list happens, or as alternative something like “list:modify(pos, value)”, which does that. I’ve just discovered the Document API as handy tool to update GUI stuff if certain things change and an own “list:remove(pos, value), list:add(pos, value)” would trigger the notifier twice.

It should not, because you then could not distinguish both cases. Changing a list or changing the values it contains usually needs to be treated differently.

“list:add(pos, value)” will only trigger one notfier. The one from the list. The value has not changed.

But values in the list are observable objects as well, so you can add notifiers to them separately as well.

-> list[pos]:add_notifier(function() print(“something changed the value in ‘list’ at ‘pos’”) end)
local observable = list[pos]

and to change the value at ‘pos’, you can do:

list[pos].value = some_new_value

Thought setting up a notifier for each value in the list would be a bit overkill when i just want to rename one, but this will do the job. Thanks.

I’ve tried to add notifiers to values in the list of[].samples[].slice_markers, which is observable, but neither of the solutions above work. I’m just getting the error: “attempt to index field ‘?’ (a number value)”

The slice marker list is observable xxx.samples[].slice_markers, but the list items xxx.samples[1].slice_markers[1] are not. So you’ll need to attach the notifier to the list instead.