How to check to see if a view exists before doing logic which would update that view

Is there a way to check to see if an element exists before trying to change a variable which would make the element visible? I notice in the newer runtime it takes the app quite some time to perform logic such as navigation, changing and setting variables, and overall performance. And if a user is used to using modern apps they will click on things too fast for appgyver to handle. Is there a way, for example, when they click on an element which has logic to change a variable to true or false, which is set to the visibility of a container, to check if the variable and element exists before tempting to perform logic which would change the visibility?

yes in each component in advanced properties, there is functionality for visibility, there you can bind a true false variable and hide it or make it visible

What I do for this case is usually having an app variable or page variable “visbility” that is a list of texts. The texts represent a name for the component I want to set the visibility. e.g.: sidebar
And then I set the advanced visibility to a formula: IS_IN_ARRAY(pageVars.visibility, “sidebar”) this returns the true/false that is needed.

Then when a user taps something that would cause a change in visibility I just add a IF flow function. Check the same IS_IN_ARRAY() as above and if true, then set the visibility to WITHOUT_ITEM(), if false, set to WITH_UNIQUE_ITEM() and it’s done. Of course we could in fact avoid using the IF flow function and put the with_item and without_item into one single IF inside the set page variable flow function.

1 Like

Yes I am aware of that. My question is whether we can check to see if that component even exists first, as appgyver seems to be slow to recognize whether components even exist. There are many crashed where the app has tried to update a non existing view on views that definitely do exist.

Im not sure what you mean with this,

but as for the crashes, maybe there is something else going on if you want to explain when it happens or share any images, we could help

I have not met anything that would solve your request.

But what I can tell is, that:
Crashes usually happen (at least in my case) when there are multiple components that change visibility on same trigger or when multiple rest api calls are done at the same trigger. Another error that is more rare is when I have a loop and the index just goes crazy. (I wire up wrong outputs of flows (sad, but occurs).

What helps in many cases is to introduce a tiny delay of up to 50-100 ms. That helps to keep the flow and order organized and easily managable by the device.

2 Likes

Thank you. I will try that. Also, is there some unwritten rule that says you cannot change the visibility of a WebView while a video is playing?

I have narrowed this issue down to the animate component flow function. For some reason if an animate component function is attached to a component, when the visibility of that component changes via variable change, it causes the app to crash with no log on debugger 50% of the time, even if the animation is complete. I fixed the issue by removing the animate component flow function alltogether.

2 Likes