elixir - 获取场景组件/场景的 PID

标签 elixir pid gen-server

快速提问,在 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/

相关文章:

elixir - 在 Phoenix 中获取原始 HTTP 请求正文

python - 在另一个脚本终止后运行 python 脚本

python - 如何在 Windows 操作系统上的 python 中根据其 PID 确定正在运行的进程?

c++ - c中如何获取进程ID,getpid()没有实现

erlang - 如何直观地描述 gen_server?

performance - 为什么 Elixir 消息传递时间与消息大小成正比?

erlang - 出于导出目的,如何在 Erlang 或 Elixir 中序列化有向图

erlang - 可以在Erlang消息上发送哪种类型的消息?

erlang-otp - 如何在 escript 中运行 Elixir Supervisor

elixir - 如何更改 Ecto 中的字段类型?