Skip to content

Instantly share code, notes, and snippets.

@neslinesli93
Created January 2, 2020 21:02
Show Gist options
  • Save neslinesli93/afdd5fd634b75e0a1ef4a3e9fc8c55fa to your computer and use it in GitHub Desktop.
Save neslinesli93/afdd5fd634b75e0a1ef4a3e9fc8c55fa to your computer and use it in GitHub Desktop.
Make event handlers functional
@spec handle_event(String.t(), map(), Socket.t()) :: {:noreply, Socket.t()} | {:stop, Socket.t()}
def handle_event("keydown", %{"code" => code}, socket) do
{:noreply, on_input(socket, code)}
end
def handle_event("keyup", %{"code" => code}, socket) do
{:noreply, on_stop_input(socket, code)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment