OnParameterChange Actions and Unused Input Variables
68
Views
3
Comments
New
References

I commonly use a Boolean variable input into blocks to trigger a block refresh for React apps. Since the variable isn't explicitly used in the block I'm stuck with a warning on the variable.
If a block has an OnParameterChange action it seems like that should clear any unused input variable warnings. Because they're being used.

The purpose of this warning is to help keep the code clean from forgotten things : something was added but developer forgot to use it, or something is no longer used, developer forgot to remove it.

If you would just say "well, there is an OnParametersChanged, so all inputs of this block are valid", you loose above function of this warning.

I understand why its there, I just don't see that being a big deal for this small specific scenario.

It seems like a larger problem that someone may remove that variable, since it says its not in use. when it is actually used to refresh block aggregates. If that happens only an end user would catch the problem.

Yes, agree that there is a real risk of someone removing it  (And I would hope it's a test catching it ;-).   

I tend to make the warning go away by actually doing something with it inside the webblock.  I use an integer instead of a boolean for this, and then add the value as a data property on one of the elements in the block, so I can see with chrome dev tools if and how often a refresh has happened, for troubleshooting.

But the real problem is that we are forced to use an input parameter as a mechanism to allow a parent to refresh it's child block, instead of having a refresh event exposed by it.  

I.e. parent should be able to trigger refresh event on child block, and child block handler of this event can then decide what aggregates or calculations or ... it wants to redo.