How do you achieve global variables in Groovy. I have looked at some examples on line but cannot get them to work. In a nut shell I have a sendHubCommand that has a callback associated with it. What I would like is to update some global variable and then use that data in another method. I have tried using
In the above example the log outputs the value the populated array from the callback method. However, when being output in ‘anotherMethod’ it is always empty. I have tried loads of different combinations but to the same avail.
How can I achieve this.
Thanks
Steve
RBoy
(www.rboyapps.com - Making SmartThings Easy!)
#2
Use state.array = […] in callback() and then you can access it from anotherMethod()