How to properly set Message Handler Scope


In this case, the sender is on a small view.
On small view -> root -> onClicked event -> sendMessage

This small view, is instantiated on a large view.
On large view -> root -> script -> message handler listening.

How do I properly set the 'minimal' scope, for communication to take place?

Hey Eugene49, for the minimal scope you will need to specify the scope in the small view when you do system.perspective.sendMessage.
In the scope parameter, you can define the scope to be "view" in order for your execution to take place.
We also have an example of component message handlers listed in our User Manual as well.

Thank you.

So I made a cheat sheet below, who's sending to where and who's listening from where.
Sender and receiver can only communicate according to scope setting strictly.

1 Like

I like that diagram, but it there are some additional aspects it doesn't cover or illustrate well.

When a message is sent ("broadcast" for the rest of this post), you specify a singular scope. This specified scope determines how broadly the message will be broadcast, whether it be limited to only this View, this Page, or all Pages (browser tabs) in this Session.

When a handler/listener is configured to listen for broadcast messages, the listener can actually have multiple scopes.

Suppose I create a message (named DEMO) to be broadcast at the view scope on DemoViewA. I also create a second message with the same name to be broadcast with a session scope inside of DemoViewB. Within DemoViewA I create a handler/listener with a name of DEMO which will listen at both the view and session scopes.

I make two pages -- PageA and PageB -- where PageA contains DemoViewA somewhere within its content, and PageB contains DemoViewB somewhere within its content. I create a session which contains two tabs; one open to PageA and one open to PageB.

If I trigger some action on PageB which would broadcast my message, then the listener/handler within DemoViewA on PageA will "hear" the broadcast message because that other page is listening for the DEMO message at both the view and session scopes.

You mean the feature where the listener can listen to multiple scope, right?

I didn't intend the diagram to be complete, but shows basicly how the communicate.

Nice to have multiple Listen scope.