openhab / openhab-js

openHAB JavaScript Library for JavaScript Scripting Automation
https://www.openhab.org/addons/automation/jsscripting/
Eclipse Public License 2.0
38 stars 31 forks source link

Update timer docs #161

Closed florian-h05 closed 1 year ago

florian-h05 commented 1 year ago

This improves the docs for actions.ScriptExecution Timers by explaining how to pass variables to the callback function.

florian-h05 commented 1 year ago

@rkoshak Would be nice if you could have a quick look at the docs changes.

rkoshak commented 1 year ago

It looks good to me. The only thing I would add is the generic case of just passing one local variable to the timer instead of this. Theoretically (I've never done it though) that too would fix the variable same as the function generator does. But you can only pass the one variable.

florian-h05 commented 1 year ago

The only thing I would add is the generic case of just passing one local variable to the timer instead of this.

That‘s possible, but …

that too would fix the variable same as the function generator does. But you can only pass the one variable.

I expect that it is not the same as with the function generator, I think you can mutate the var after the creation of the timer. I have to test this to check my assumption.

I will modify the docs to have two ways of passing a var to a timer, both ways support this. The main difference should be that in one case the var can be changed after timer creation.

florian-h05 commented 1 year ago

@rkoshak Ready for re-review.

rkoshak commented 1 year ago

Once that comment is added I think this is good to go.