[question] system.perspective.sendMessage return value?

Any plans for system.perspective.sendMessage to return a value?

What sort of value would it return?

The philosophy of Perspective’s sendMessge() use is more or less like a radio broadcast; if you’re tuned in (listening on the right channel and at the right scope), you can hear the broadcast message.

But a radio station doesn’t know that you have your radio tuned to their station.

If you want something along the lines of a send/response communication, you’ll need to configure an additional sendMessage going the OTHER way, which would turn the components into something approaching walkie-talkies.

3 Likes

He’s asking for an equivalent to system.util.sendRequest.

1 Like

@Kevin.Herron is correct. I’d like to return whatever if needed. If there’s no intent of sendMessage returning then your suggestion will work.

One main difference is that system.util.sendMessage() will only ever reach one handler on the other side - there’s no way to have multiple message handlers handle the same message.

Perspective’s message handling is inherently different - not only can you have multiple identical message handlers, you probably should if you’re using message handlers to their full potential.

2 Likes

I know this is an old thread, but I have a follow-up question. I like using sendMessage to set values, but how can I get the content of several fields without explicit paths? I need to get the content of several text fields which will then be used as parameters for an SQL query. I haven’t found a way for my query script to request the data from the fields without explicitly using the path to the appropriate props.text property.

With… sendMessage of course!

For whatever fields you need to supply to your query, set up a propertyChange script for each of the components which uses sendMessage to broadcast their new value.

Configure the component which will execute the query to have custom properties - one for each required query parameter. This component should also be listening for all of the message types and on appropriate scopes. When it “hears” a messageType, it should set the corresponding custom property with the new value. Then, configure the query to read from this component’s custom properties, instead of linking it to other components.

Text Field component property change script:

system.perspective.sendMessage('UPDATEBAY',payload={'bay':self.props.text},scope='page')

Query Button Message Handler:

self.custom.bay = payload['bay']

Query Button onActionPerformed Script:

system.db.runSomeQueryMethod('select pallets from warehouse where bayName={0}'.format(self.custom.bay), other_args)

Thanks. I’ll try that. I set properties at the view level for now, using sendMessage, so they wouldn’t be affected by any component changes.