Calling view template methods

Hello.

I have a view template with some components interactuating between them. The view template has also some methods intended to be callable from outside (as an API), and which also call to inside components methods. But, if I dock the view template in a main view, when I call to the "API" of the docked view, the methods aren't found.

Is that logic correct? If it's not, could I call the "API" (in some way) from a new method of the "instanced" view?

Thank you for the help!

This is what messages are for.

Create a message, and use an identifier in the payload so that when you handle the message you can verify that the payload is intended for the view handling it.

1 Like

Thank you! I'll see it.

For this, I normally have a function in a script library to gen uuids such as:

from java.lang.System import UUID
def getUUID():
    return str(UUID.getRandom())

And call this within a custom prop binding (expression binding set to simply 1, script transform to call genUUID) on the button that calls the send message, and include that in the message.

Setting the expression binding to 1 (or anything really) will just cause it to run once on load, so the uuid generates once. You could also put it on the onStartup script, but it less obvious there

2 Likes