Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State #2

Open
kitallis opened this issue May 30, 2020 · 0 comments
Open

State #2

kitallis opened this issue May 30, 2020 · 0 comments

Comments

@kitallis
Copy link

kitallis commented May 30, 2020

Hi!

I'm new to Phoenix/Elixir and I watched your talk on Presence and went through the code. I'm curious about the split of the state here:

The currently selected programming lanuage and tracked and broadcast with the help of the ChallengeChannel.Monitor module which leverages GenServer to store the language in a "channel state".

&

The tracking of which user is currently typing is managed by the ChallengePresence module. This module leverages PhoenixPresence to track user state in the channel and expose it to all subscribing clients.

I'm building a little game of my own and I discovered Presence a bit too late in the day.

The way I've modeled it is the following:

  1. HTTP endpoints that bootstrap a GenServer (with Game state) driven by a cljs frontend.
  2. All post-joining/creating communication happens over channels within the game that communicate with that GenServer to update the state.

My question is,

Now that I've done all this, I feel like most of it could be better done through Presence, but I'm still uncertain. I'm curious why you chose to split your challenge state in a GenServer and more ephemeral state in the Presence?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant