Another one I really dislike
def handle_event("show_modal", %{"modal" => "create_column" = modal}, socket) do
{:noreply, assign(socket, show_modal: modal, changeset: Column.changeset(%Column{}, %{}))}
end
def handle_event("show_modal", %{"modal" => "create_task" = modal, "column_id" => column_id, "top_bottom" => top_bottom}, socket) do
{:noreply, assign(socket, show_modal: modal, changeset: Task.changeset(%Task{}, %{}),
column_id: to_integer(column_id), top_bottom: top_bottom)}
end
gets transformed into
def handle_event("show_modal", %{"modal" => "create_column" = modal}, socket) do
{:noreply, assign(socket, show_modal: modal, changeset: Column.changeset(%Column{}, %{}))}
end
def handle_event(
"show_modal",
%{"modal" => "create_task" = modal, "column_id" => column_id, "top_bottom" => top_bottom},
socket
) do
{:noreply,
assign(socket,
show_modal: modal,
changeset: Task.changeset(%Task{}, %{}),
column_id: to_integer(column_id),
top_bottom: top_bottom
)}
end
Now my eyes have to move a lot to find which clause will be called. That’s typically a place where I want to keep control of the line breaks.
But maybe I’m too old
(at least my eyes are…)