Getting the PID of a scenic component/scene

Viewed 67

Quick question, in the Scenic docs it suggests that you can interact with any scene as you would any GenServer:

You are free to send your own messages to scenes just as you would with any other GenServer process. You can use the handle_info/2 , handle_cast/2 and handle_call/3 callbacks as you would normally.

I understand how this would work, but I’m unsure of how to actually get the PID of the scene to send messages to.

Using observer theres a table called _scenic_scenes_table_, but i’m guessing that’s not a public API.

I hope I’m not missing anything too obvious.

Thanks for the help

1 Answers

Kernel.send/2 accepts the destination of type Process.dest() which can be pid(), port(), or registered_name.

As scenes are registered this would most likely work:

send(MyApp.Scene.Example, {:my, :info, :message})
Related