As someone who currently writes applications using React Server Components, I am interested to see how concepts like LiveView evolve over time. We are now shipping significantly more HTML than before, and a lot less Javascript, as more has been moved to the server.
Makes me wish LiveView was portable to every other platform I work on, rather than having to convince companies to write more Elixir (although that isn't a bad thing).
It uses the same front end javascript from Phoenix and speaks the same protocol.
Note: am author
My apologies for the terrible elixir syntax highlighting in this post. I keep putting off finding a good way to do this on Blogger.
import Phoenix.Socket, only: [assign: 2, assign: 3] import Phoenix.Component, only: [assign: 2, assign: 3]
https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#...Importing from Socket should work, but you're right, the code in the post wouldn't work. They use to be in LiveView but got moved to Component.
You can write a test that just fetches the disconnected state, and then upgrades it to a connected state (see https://hexdocs.pm/phoenix_live_view/Phoenix.LiveViewTest.ht...).
If you want to test the result of a button click there's support for that, too, with things like `render_click`.