(2.1.0, API) Revising the Show/Hide mechanism

If a module currently hides an other module (let’s say, for example by using the facial recognition module) and an other modules hides and shows the modules (for example my mqtt-alarm-welcome module), stuff get messed up. The second module shows modules that still needs to be hidden …

I’m thinking about changing this behavior, by letting modules take a hidden lock on a module. This means the module will not appear as long as that module does not say it should be shown. This could be done by using a lock identifier (which could simply be the module’s identifier).

To explain it a bit better, here is the scenario with a 3-module mirror (all code below is just as an example, not real code):

Module B asks module A to hide:

moduleA.hide(lockString: "module_b_identifier");

Module A is now hidden, and has an lock array with the following strings:

moduleA.locks = [
"module_b_identifier"
]

Module C asks module A to hide:

moduleA.hide(lockString: "module_c_identifier");

Module A is now hidden, and has an lock array with the following string:

It’d be nice if there was also a way to override the array completely. What I mean is, if Module A hides a module, then Module B says to unhide, even if the locks don’t match, having an override, or ‘force’ flag, that would be handy. This applies for multiple modules as well, if Module A hides something, then Module B does the same, then allow either of them, or potentially even a completely different module, to overwrite the array and show the module again.

This wouldn’t be the default behavior, but having a ‘force’ flag would then allow the user to specify that.

Yeah, but I think that is the exact reason why this method should be implemented. One can argue what the desired result is. But by implementing the force option, both scenarios will be possible. Implementing a force function isn’t really a big deal.

@MichMich Did you have any concerns about making this an opt-out instead of an opt-in? I.e. make the default options {this.identifier} instead of {}. Or is there a specific reason against it? The overall concept seems reasonable, if we assume the meaning of the hide() method always was to “keep this module hidden until I want it to reappear”.

I do not think anyone does something like hiding module A from module B and then purposely showing module A again from module C. This is the only way I think of, which would make the default option using the modules identifier weird.