Creating a gateway function that calls a javascript function

I am trying to implement a solution to display toast notifications using the library:

Is there a way to implement a gateway function, like toastify(message), that I can call from my Python scripts to send a message to Perspective and trigger the Toastify({...options}).showToast() function?

Since the library handles element creation automatically, there's no need to create and manage a custom Perspective component. Is something like this possible?

Yup, you can do this. See Embr-Periscope for inspiration:

  1. On the Perspective client-side, add your own message handler to the ClientStore's connection.
clientStore.connection.handlers.set('your-protocol', (payload) => { ... } )
  1. On the Perspective gateway-side, trigger this message by sending a message to a Page.
page.send("your-protocol", payload)
3 Likes

Thanks for the reply. This seems to be what I need :+1:

1 Like