Accessing temporary state from app-level Javascript

I'd like to access and modify temporary state from an app-level Javascript function (I'm in a mobile app). The reason is that I would like to define a few top-level utilities to manage temporary state, which I can then call from individual queries.

I tried to access the state by its name directly in an app-level function (e.g., state1), but that doesn't exist. I tried accessing the state from the window (i.e. window.state1), but that didn't exist either. I inspected the window object, but couldn't find any place where the temporary state might be stored.

Does anyone know how I can access temporary state from an app-level Javascript function?

Hey @e.rabbath! Would you mind sharing a screenshot of your app-level JS?

It doesn't look like you can directly access your temporary state value from inside your app level JS, but you can do something like this (pass it in):

Would this work for you?

Hey @victoria ,

That's a pretty good solution, and I can make it work for my use case, thanks!