I'm trying to set a default value for a property before the binding is executed in Perspective.
Here's the situation:
I have a button whose text is bound to a custom property called "datetime" The "datetime" value is only available after 500 ms, which is the time it takes for the binding expression to evaluate in the view.
During the initial 0-500 ms period, the button displays the text "button," which is not what I want. I would prefer it to show something like "loading" until the actual date is available.
I've tried using a persistent property, but if I save my project while a date is shown, that date becomes the default value.
Do you have any suggestions on how to resolve this issue?
Set the property back to transient, and try something like coalesce(path.to.property, default).
I'd expect the prop to be null before the binding evaluates.
Transient is the opposite of persistent. So, make it not persistent, like it was before.
Without this, The property won't have a value, so you should be able to use coalesce.
My bindings never took 500ms to evaluate. Hence my question: What is it evaluating ?
Here is the whole script, added a line to edit the text at start, the button text appears although for approximately 300ms then "Hiiiii" appears in a second time.
The problem is that button component shows text "button" by default before the binding is evaluated when text is not persistante.
Edited:
If you just try add button anywhere and set text property to not persistante, the text that will be shown is "Button" by default and i think that it is a bug.
You should just paste/attach images/gifs/videos directly into your posts rather than uploading them to other sites that will most likely delete them
Edit: I just realised it was 35MB for a gif using dithering??
Scratch that, use a proper screen recorder like ScreenToGif. That video should be 1MB max
Why would the text of a button not be persitant? Just because it's behavior is unexpected by you, doesn't mean that it's unexpected behavior for the developers.
I understand what you are saying the issue is, but what I am interested in is why? Why are you changing the text on a button?
It's a button which will display the start date of production of my machine and as i click i will get the previous date and so on. At the view startup, the button displays "button" before its gets the right date.
I understand that it’s a button that is displaying a date. That’s more What the button is doing not why.
The text could just as easily say “Previous Date” and be persistent and then your problem presumably goes away. But without understanding why you’re changing the text on the button rather than in a datetime component, we can’t really suggest any other work around than “deal with it”.
I don’t think this is a bug, I just think the default value is “Button” when the value is null.
At the start-up for every non-persistent binding the value will be null.
yes i tried your solution, but i faced new issue which has the same cause, if i want to disable the button when the date is after now, i will get the button enabled before the expression executes.