zachdaniel
LiveView: Feature to "cancel" second render
One thing I find is that I typically “start” with a LiveView even for static pages (in cases where I know I’m likely to add interactivity). I think it would be really awesome if we could do something like this:
def mount(...) do
socket
|> assign(...)
|> cancel_second_render()
end
This would essentially say “this is a static page. Don’t connect to the web socket, just render the HTML and be done”.
This means that you can have the benefit of a static html page very easily, without redesigning everything as a “dead view”. This is especially useful when you have that feeling “I know some day later I’ll probably want this to be a liveview”.
Most Liked
steffend
https://github.com/phoenixframework/phoenix_live_view/pull/3704
This PR introduces a new mount option called auto_connect. By default, it is true, which means that the LiveView JS will automatically connect to the server on dead render. If false, the connection will be skipped. The important difference compared to a no_live(socket) approach is that it does not suggest in any way that we should not connect when navigating from another LiveView when already connected.
benwilson512
Ya I think the easy way to roll this is put a data element on the body tag or something that uses a “@nolive” assign you set on the static render. Then in the JS code you check for that to be true and if it is, just don’t run the LiveView JS code.
Kallee
If that’s the case then I’m surprised this suggestion & thread has not gotten more attention as it could have quite significant impact on both how LV itself is used and its role within phoenix?
I quite often see statments such as “LV is not good for this or that”, especially for static marketing or landing pages and this, if implemented, seems to then invalidate such arguments if I understand the situation correctly.
Popular in Proposals: Ideas
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









