Is persistent the setting I need

Hi everyone,

Looking to get some clarity if this is the setting I need.

Basically I have a toggle switch. If I toggle it and go to a different screen and come back I want that toggle to stay where it is at. I tried going through the manual and it mentions persistence so I checked the selected property and sure enough it is selected but it does not save. Should I be looking at another setting?

1 Like

You need to bi-directionally bind the value to a session custom prop. That should keep it across page views.

To expand on what @bschroeder has already mentioned, what you're describing is the idea of a component maintaining its state during the life of a session; going to a different screen (View OR Page) results in that screen being removed from the session registry, and a new instance being added when you then later come back to the original screen. By placing a property at the session level and using this Toggle Switch to set that property through a bi-directional binding, the Toggle Switch will both set and reflect the value of that property.

Now, Persistent is a binding setting - configured within the Designer - which dictates what value the component loads with on startup. When you place bindings, you'll notice they have Persistent turned off by default. This is because the most common use-case is that you want the component to evaluate its binding before showing a value. If Persistent were enabled, then the component would render with whatever is saved in the Designer while the binding might still be evaluating in the background resulting in "thrash", where components load in one state and then visibly swap to another state (or value).

2 Likes

Oh ok yea that is what I need. Thank you both!

So to understand this correctly Persistent is what value to pull at session start either what is in the designer or evaluate it as its happening when starting up?

While this session custom tag is what is used when creating something that will clear to default after the session ends?

And just to make sure there is no way to do this with persistent?

Not quite. It's what value to display while the binding value is being retrieved or calculated.

Not quite. When the session ends the session variables are erased - gone - they don't exist - not to be found - anywhere. The browser frees up the memory they were consuming. Something that doesn't exist doesn't have a default value.

1 Like

Oh ok that makes sense thank you