获取场景的 PID component/scene
Getting the PID of a scenic component/scene
快速提问,在 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。
使用观察器有一个 table 叫做 _scenic_scenes_table_
,但我猜那不是 public API。
我希望我没有漏掉任何太明显的东西。
感谢您的帮助
Kernel.send/2
accepts the destination of type Process.dest()
可以是 pid()
、port()
、 或 registered_name
.
因为场景是 registered 这最有可能工作:
send(MyApp.Scene.Example, {:my, :info, :message})
快速提问,在 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。
使用观察器有一个 table 叫做 _scenic_scenes_table_
,但我猜那不是 public API。
我希望我没有漏掉任何太明显的东西。
感谢您的帮助
Kernel.send/2
accepts the destination of type Process.dest()
可以是 pid()
、port()
、 或 registered_name
.
因为场景是 registered 这最有可能工作:
send(MyApp.Scene.Example, {:my, :info, :message})