I’m learning Phoenix and OTP by making a simple game. I’ve asked somewhat related to this topic but it’s not really yet clear to me the usage of DynamicSupervisor and GenServer.
My app index page is a LiveView page which displays all the games (Standy, Started, Ended). It also has a button which would create another game. Now new game is created, DynamicSupervisor starts a child with a named Genserver using Registry and via_tuple.
When a particle route together with its id as route param is clicked on the home page, I can then easily calls rhat specific GenServer and manipulate states when the game started or ended.
So far what I’ve understood is in order for me to display all I think I need to know the processes under the supervisor (maybe I need supervisors which_children) and access their own state. I dont know how to access the states of the supervisor children.
My analogy regarding GenServer and DynamicSupervisor when applied to my game requirements.
DynamicSupervisor spawns
Game 1 (GenServer)
Game 2 (GenServer)
Game 3 (GenServer)
Please correct if I’m wrong. Sorry for the noob question.
If there are things to clarify, please let me know.
Thank you.