Bind property directly to scripting instead of passing through an expression and a transform

Hello, is it possible to bind a property to a script directly without first creating an expression which returns true and then adding a transform which executes the Python code we need?
We have several points in our project where we basically have empty expressions which return True just to be able to use Python code.

A start upscript could fill in all your props without having to use any bindings.
I use empty expressions too tho xd

custom methodes and eventhandlers could do this too, but a static expression just triggers once at startup rly (unless you use refreshBinding which would be weird for something like this)

What are you actually trying to do with these transform scripts? A transform is meant to transform a value from a binding or an expression, this certainly isn’t the right use-case for this and as Victor mentioned, there are other ways to fire a script to run once

it happens frequently, for instance to store the content of a json configuration file inside the variable what we do now is create a binding and then we are forced to create an Expression first and then a transform which reads the configuration file.
I make the example of reading a configuration file because it’s something which expressions cannot do but it could be really anything which is too complex to translate into an expression.

What happens to trigger the store of the json configuration file in your example? Is it user interaction or something else?

you should not use properties to store this, properties are send back and forth to the client-gateway, for big files this takes up quite the traffic… why would you even need to store a file in a property? It is already stored on your device/gateway !

I think I’ve been misunderstood, we use json config files to keep few lines of configuration options in JSON format which some views might need to read, we do this to avoid having to store these options in a database and then fetching them via a query or hardwiring them in some variable.
It works and it’s quite flexible because we have config files which store configuration for multiple views which can be changed just by changing a single config file.
This is only one of 1000 possible scenarios where we might need to bind a variable to a script, I see no reason why I am allowed to bind an expression to a variable and not a script directly.
I hope it’s clearer now.

Ah so in the script you read out the one line of the file that you need for that particular property?

No it is not possible to do a binding with just a script, as bindings get triggered by (something similar to) “onchange” in javascript. So it needs something to get triggered, in your case it gets changed from undefined to ‘true’ only once on startup.

If you do not want to do this in bindings you should do it in the startupevent of the component and there call all the props you want to set. (this also centerlizes all your startup config code in one place for a good overview, tho it does remove the binding symbol)

This particular scenario should be done in the component startup event, or baring that a change script of the property that would at least give you an indication that the property is being written to.

As far as I know you have never been able to bind to a script directly, not even in vision.

Bindings are more of an alias than anything, its a way of saying this property should be equal to that value. Instead, scripts are triggered by an event. I have yet to run into a situation where I needed to bind a property directly to a script.

In the ‘less ideal workarounds’ category, there’s also the runScript expression function. I agree with everyone here that in this case, you’re best off with a different scripting hook, but runScript can be useful.

Consider reading the json file into a json object kept in the top level of a project script module. Then your runScript() or whatever can simply have the one-liner that accesses that object.