HomeGenie Forum
General Category => Troubleshooting and Support => Topic started by: pim555 on February 02, 2015, 09:57:13 PM
-
Hello,
I am having trouble in understanding how events are being handled within HG. I have a piece of code that looks for parameters changing:
When.ModuleParameterIsChanging((module, parameter) => {
What is not clear to me is what exactly happens when you return true or false from within this iteration?
Cheers
Pim
-
True stops the iteration, false continues on.
If you have several modules that change at the same time and you want to do something when one of them changes, you would want to use false at least until the module you are searching for has been dealt with. If you want to be complete, you should continue to return false but you could instead return true to kick out at that point too. Depends on your goal.
-
hey bkenobi,
that's not the purpose of the return value for ModuleParameterIsChanging (http://www.homegenie.it/docs/doxy/d4/dd7/class_home_genie_1_1_automation_1_1_scripting_1_1_events_helper.html#a2345d703592c2fe90284b13ce7ac2650) event.
If the return value is true, HG will continue propagating the event to other possible listeners (other programs that are listening to the "parameter is changing" event).
If the return value is false, HG will stop propagating that event (other listeners won't receive it).
Cheers,
g.
-
Wonder if that caused issues when writing the Advance Smart Lights code. Doh! :-[
It's working, so I guess it must not be an issue.
-
Gene, I guess it's the same way for ModuleParameterChanged. Is it ?