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

Simplify ShowLive to avoid handle_params #6059

Merged
merged 2 commits into from
Jan 26, 2025
Merged

Conversation

josevalim
Copy link
Member

No description provided.

@SteffenDE
Copy link
Contributor

I do wonder if this is something that will confuse people as soon as they adjust their ShowLive to use something that patches the LV.

[error] GenServer #PID<0.829.0> terminating
** (UndefinedFunctionError) function TestappWeb.PostLive.Show.handle_params/3 is undefined or private
    (testapp 0.1.0) TestappWeb.PostLive.Show.handle_params(%{"foo" => "bar", "id" => "1"}, "http://localhost:4000/posts/1?foo=bar", #Phoenix.LiveView.Socket<id: "phx-GB49kUwpUq_z4wAl", endpoint: TestappWeb.Endpoint, view: TestappWeb.PostLive.Show, parent_pid: nil, root_pid: #PID<0.829.0>, router: TestappWeb.Router, assigns: %{post: %Testapp.Blog.Post{__meta__: #Ecto.Schema.Metadata<:loaded, "posts">, id: 1, title: "test", body: "123", inserted_at: ~U[2025-01-26 12:22:20Z], updated_at: ~U[2025-01-26 12:22:20Z]}, __changed__: %{}, page_title: "Show Post", flash: %{}, live_action: :show}, transport_pid: #PID<0.821.0>, ...>)
    (phoenix_live_view 1.0.2) lib/phoenix_live_view/utils.ex:456: anonymous fn/5 in Phoenix.LiveView.Utils.call_handle_params!/5
    (telemetry 1.3.0) /Users/steffen/oss/phoenix/installer/testapp/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3
    (phoenix_live_view 1.0.2) lib/phoenix_live_view/channel.ex:148: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 6.0) gen_server.erl:2173: :gen_server.try_handle_info/3
    (stdlib 6.0) gen_server.erl:2261: :gen_server.handle_msg/6
    (stdlib 6.0) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

@josevalim
Copy link
Member Author

If that's the case, then we need to improve the error message in LiveView. But a general rule we follow with generators is to avoid "future code": adding features and code in case someone may need it, as that's an easy way to bring a lot of complexity.

@SteffenDE SteffenDE merged commit bd589f1 into main Jan 26, 2025
9 of 10 checks passed
@SteffenDE
Copy link
Contributor

Thank you! I'll send a PR to improve the warning in LV.

@SteffenDE SteffenDE deleted the jv-no-handle-params branch January 26, 2025 15:33
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

Successfully merging this pull request may close these issues.

2 participants