How to safely refresh Flow Diagram (vCortex) in Perspective?

Hi, I’m trying to refresh the vCortex Flow Diagram component from a button click.

I clear the nodes/edges and then call my loadFlow() function:

flow.props.nodes = []
flow.props.edges = []
flow.props.layouting.autoLayout = False
self.view.custom.flowNodes = []

time.sleep(0.1)   # temporary delay
self.loadFlow()

Because Perspective property writes are async, the load runs before the clear finishes, causing inconsistent results.

invokeLater does not work in Perspective from this scope, and I know using sleep() is not ideal.

Question:

What is the correct or recommended way in Perspective to add a small delay or queue the load so it runs after the clear is applied?

Thanks!

Searching for the word “delay” in the forum brings up a lot of suggestions….some are better than others.

My favorite method when needing a timer on a Perspective view is to use a custom prop like this:

it seems you have problem and need this delay to make autoLayouting work. In that you can use system.util.invokeAsynchronous() and add your sleep timer inside.

I believe in next release we can an event to fire when the Flow diagram internal loading of nodes and edges are finished.

It’d be nice if there was a first party way to submit functions to the back of the session’s queue.

invokeAsynchronous is pretty heavy handed when all you’re trying to do is run a function after property assignments are complete.

I have an unmerged system.perspective.queueSubmit function in Embr Periscope that does exactly this:

Unmerged because I got busy and never finished testing it all the way.

2 Likes