phoenix-playground / phoenix_playground

Phoenix Playground makes it easy to create single-file Phoenix applications.
157 stars 8 forks source link

Are `on_mount` hooks not supported? #9

Open doughsay opened 6 days ago

doughsay commented 6 days ago

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)