Phoenix.Channel handle_in/3 function with only 2 arguments?


on the Phoenix.Channel hexdocs page one of the examples is using the handle_in/3 function with only 2 arguments:

def handle_in("current_rank", socket) do
  push(socket, "current_rank", %{val: Game.get_rank(socket.assigns[:user])})
  {:noreply, socket}

The documentation for the handle_in/3 function further down on the page does not mention anything about optional arguments. There also is no mention of a handle_in/2 function.

Might somebody be able to help me understand how this works?

Thank you very much.

It is probably a typo in the doc… maybe it should be

def handle_in("current_rank", _payload, socket) do

But sure, You need to pass 3 parameters.

Ah, thank you, that helps with the head scratching :slight_smile: