zachdaniel
Creator of Ash
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”.
Trending in Proposals: Ideas
I’m a bit in a fuzz about this topic. I’ve worked out some sort of Dropbox feature for a specific client. This feature allows him to uplo...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
I‘ve thought about this as well in the past, but with live navigation I’m wondering if not starting the websocket is actually useful. I agree that being able to skip the second render would be nice though, given it‘s mostly needed for change tracking and asserting confidence over the match between server side state and local state.
zachdaniel
Curious how live navigation works in between the first and second render. Or just while the ws is not connected. Do they in some way fall back to “regular” links?
mayel
If you simply don’t include the LiveView JS in the HTML of a page it won’t connect to websocket and won’t re-render.
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.
LostKobrakai
They fall back to normal links doing navigation through the browser and plain http. But if you can you don‘t want this to happen, but rather opt for what live navigation does, which only happens via the websocket connection, skipping the http level additional render. Switching constantly between live and non-live pages kindoff denies making use of that optimization.
KP123
I wish we had separate
load/3andmount/3functions. That plus being able to return json fromrender/1would allow me to never use controllers again.zachdaniel
Yeah, thats an interesting idea
Next time I have a case for it I may try that out, because that could at least provide the concept. I think having it in core sends a signal that it is okay to actually do that kind of thing (i.e you won’t break anything by not running the second render), but it makes sense to try the manual approach first.
sodapopcan
Along these lines I would love it if event handlers could somehow be routeable. This would allow for truly progressive web apps (if you need it). I know there would be issues with this—for example and code that uses
sendwon’t work anymore and it will probably become a come repeated question on this forum—but it could allow using most features for static HTML + POSTs.Something like:
Very much spitballing here though have been thinking about it a little bit.
Hermanverschooten
You could check for the
transport_idin thesocketand pattern match on it.If it is
nilyou are not yet connected.stefanluptak
Isn’t Phoenix.LiveView — Phoenix LiveView v1.0.0-rc.7 meant for this?