Page 1 of 1

Trigger "global variable"

Posted: 15 May 2015 21:41
by TheBrain1984
Can it be that the trigger won't be triggered if the global variable is a list and you add or remove an element? Is this a bug or a feature?

Re: Trigger "global variable"

Posted: 16 May 2015 13:19
by Martin
This is a "feature". The trigger will only execute when another value is assigned to a global variable. This design decision was mostly done for performance and simplicity reasons since Automagic otherwise would have to monitor each list and map for modifications which would greatly slow down modifications of such structures.
You can avoid this issue by assigning the size of the list to a separate global variable when you modify the list and by triggering on the size variable or by creating a copy of the list and assigning this copy to the global variable when the modifications have been applied, for example:

Code: Select all

list = copyList(global_list);
addElement(list, "xyz");
global_list = list;