I have had now many occasions where I would have used a custom widget as a fill-in function to perform some more complex calculations or lifting, like parsing some incoming encoded data, barcodes, etc.
In a lot of these occasions I would have like the widget to not evaluate immediately on load but rather only when I explicitly tell it do so.
My current workaround for these scenarios is to create a placeholder trigger text prop. In the corresponding getValue function the first thing I then do is to check for NULL. If it is NULL I return early from the function. If it is not, the code continues evaluating. With this in place I can then trigger the widget anytime by writing something (random string) into the trigger prop it is monitoring. To stop it from automatically re-evaluating the next time I enter the corresponding step I set the monitored trigger prop back to NULL again.
While this has so far worked on desktop, I seem to have uncovered some sort of rare event (probably a race condition of some sort) on Android where this setup will cause the widget to enter an endless loop. Support has been looking at it but so far to not much avail. In my original solution the last command I sent out was a setValue call to set the trigger prop back to NULL. This approach seems to occasionally fail on Android (tested v8.1, v12) as it would enter an endless loop.
Hence I have resorted to commenting out that last setValue command and replace it with a end trigger with gets fired instead. In this trigger I then place the prop clearing action.
After all, it would be awesome if there was a trigger action available through which I could send a trigger signal directly to a widget at will.
Not working in a stable fashion at present, as explained:
getValue("Trigger", trigger => {
if(!trigger) return;
[...]
setValue("Trigger", null);
})
Workaround for the workaround:
getValue("Trigger", trigger => {
if(!trigger) return;
[...]
fireEvent("On End", null); // <--- with clear data manipulation for the Trigger prop variable
})