phoenix_playground icon indicating copy to clipboard operation
phoenix_playground copied to clipboard

Are `on_mount` hooks not supported?

Open doughsay opened this issue 1 year ago • 1 comments

Hey, amazing project! I love it for doing quick tests when helping people out in the discord server.

I tried this, and it appears the on_mount hook is never called. Is this intended right now?

Mix.install([
  {:phoenix_playground, "~> 0.1.0"}
])

defmodule Demo.Hooks do
  def on_mount(:default, _params, _session, socket) do
    dbg("on_mount!")
    {:cont, socket}
  end
end

defmodule Demo.Live do
  use Phoenix.LiveView

  on_mount(Demo.Hooks)

  def mount(_params, _session, socket) do
    dbg("mount!")
    {:ok, socket}
  end

  def render(assigns) do
    ~H"""
    <p>Hello!</p>
    """
  end
end

PhoenixPlayground.start(live: Demo.Live)

doughsay avatar Jun 26 '24 22:06 doughsay

Hey, good catch. A PR that would enable this would be appreciated.

wojtekmach avatar Jul 08 '24 08:07 wojtekmach