1

I am building a simple application and need to update an Environment variable when a navigation link is clicked. To do this I placed a simultaneous gesture with the navigation link to run when the link is clicked. There I will update my variable so that when the new page is opened it can read that updated variable. I basically need to pass the variable to initialize the page but can't seem to get this simultaneous gesture to run. It runs sometimes and sometimes it does not. It is not dependent on short or long clicks either, it seems to be random.

Here is a snippet of the code

UserLoggedIn is my environment object which needs to be updated BEFORE the new page loads

  • The print statement only prints sometimes. so frustrating – Ron Jones Jr Apr 18 '22 at 18:10
  • Welcome to Stack Overflow! Please take the [tour](https://stackoverflow.com/tour) and see: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Reproducible Example (MRE)](https://stackoverflow.com/help/minimal-reproducible-example). Please don't post images of code, but rather post a minimal example that we can copy and paste to help debug. – Yrb Apr 18 '22 at 20:08
  • 1
    Does this answer your question? [Is it possible for a NavigationLink to perform an action in addition to navigating to another view?](https://stackoverflow.com/questions/57666620/is-it-possible-for-a-navigationlink-to-perform-an-action-in-addition-to-navigati) – Ptit Xav Apr 20 '22 at 11:19

0 Answers0