Perspective: run script when View is fully loaded

What is the best way to run a script once the entire View has loaded, params, components, tag subscriptions and all? Is this possible at the moment?

Additionally, what about at least when all View params are loaded?

The onStartup event seems to happen at the very start when the view is launched, and seems to run concurrently to everything else loading, so you can’t guarantee that anything else is loaded when this is run.

Context: I sometimes have lists for things like Flex Repeaters that are generated by script from the params that are passed in, but these need to run once at least the params passed into the View are set.
I’ve resorted at the moment to running this script off an on change of a custom prop that is bound to a param, but this doesn’t work if the param hasn’t changed…

There’s no current way to hook into the load process of a View. That being said, you can approximate completion based on some values if you’re setting them via script. In the script which drives your Flex Repeaters, set a separate custom flag after the repeater instances have been set, then apply a change script to that property.

# logic to create instances based on params
self.props.instances = instance_data  # assuming this is in the flex repeater
self.view.custom.instances_done  # this property should have the change script

If multiple conditions have to be met, then change the instances_done property to an object with descriptive keys and wait for them all to become True.

complete = {
    "instances_done": False
    "params_loaded": False
}

With this setup, you could bind params_loaded to verify that some or all param values are no longer their default as you see fit.

You could also have a separate single-value property which is bound to each property of complete as part of an expression structure where you’re just returning an and of each key’s value.