快速提问,在 Scenic 文档中它建议您可以像与任何 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.
我知道这是如何工作的,但我不确定如何实际获取场景的 PID 以向其发送消息。
使用观察者有一个名为 _scenic_scenes_table_
的表,但我猜那不是公共(public) API。
我希望我没有漏掉任何太明显的东西。
感谢帮助
最佳答案
Kernel.send/2
接受类型为 Process.dest()
的目的地可以是 pid()
、port()
、或 registered_name
。
因为场景是registered这很可能会起作用:
send(MyApp.Scene.Example, {:my, :info, :message})
关于elixir - 获取场景组件/场景的 PID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63032206/