How Phoenix LiveView Works
poeticoding.com
poeticoding.com
This isn't necessarily an issue with LiveView in particular, but it's the only experience I've had with it.
Yeah, I don't agree with everything he says -- I don't think boilerplate is necessarily bad. Especially in Elixir where It's hard to explain but usually it's easy to find the meat of what you care about -- your eye (or search cursor) just lands on it. And I also think specifically the solutions he proposes are not that great. Having a common language and not inventing too many more DSLs has value, even if it sucks a bit. But a lot of that shit needed to be brought up.
With a SPA, you instantly get a visual response when you click something (even if this response is a spinner) while with this kind of tool, there is a small bu weird delay (because of websockets) that makes the whole experience laggy, and pretty weird to me, especially after being used to SPAs.
I totally understand that the balance between the tasks to achieve and the end result is very good, but this techno does not look like a replacement of SPAs to me.
On the other hand, I think it is a failure of the UI, but not of the whole LiveView concept. UI elements could get an automatic visual indication of being "in progress" on the client side after being clicked, and I believe the feeling of lagginess should go away.
2) it's possible to combine both approaches, using bits of javascript to fill in client-only animations etc.
Good practice seems to be the PETAL stack (https://thinkingelixir.com/petal-stack-in-elixir/) using Alpine.js to sprinkling in some client side UI stuff that doesn't need to go via the server.
LiveView isn't intended to replace SPAs. If you have a lot of UI interaction where the UI changes "shape" in response to user interaction then no you probably want JS. For a lot of things people are doing they don't need that though.
Implementing a form in LiveView is a use case that completely shines. You implement all your validation once on the server and use that same validation code (the ecto changeset stuff) to do your live UI messages in the client. It also doesn't matter if it takes 100ms for the text box to go red and say "password too short" in that use case. You can get a 'live' friendly and helpful interactive form with all the user feedback you want and it costs you barely more than the effort to do just the server side stuff, and without any risk of mismatching validation.
I wrote about UX considerations with LiveView here that addresses these points: https://dockyard.com/blog/2020/12/21/optimizing-user-experie...
However, I guess there is still a UX difference with SPAs when you go to a new page. Going to another page with a SPA is instantaneous, and user just waits for server-side data to be loaded, with data with spinners in between. But with Liveview, the client would need to wait for the server to render the whole new page, before displaying anything new (exactly like a standard MVC framework). And this specific behaviour can create a "laggy feeling" IMO. This will never be as fast as a SPA in this case. I think this can be disturbing, especially for websites used as mobile apps. In that case, users expect navigating between app pages without waiting at all, even if they are used to to wait for specific data to be loaded in that same page.
Please correct me if I'm wrong, but to me, it seems Liveview is perfectly suited for intensive data exchange on an open page (for example, the bitcoin example used in this video seems perfect), but not suited for apps with an intensive navigation between different pages, because that pages will require a round trip to the server to be rendered.
Still, I'm jealous there is no Liveview equivalent in Python, so that I would stop requiring the whole SPA toolchain as soon as I need some updates in my project.
I really don’t see any reason why we can’t embed LiveView widgets into existing SPAs as a method of transition. Looking at this lifecycle it seems entirely possible. Also it would make an amazing framework for embedding widgets on third party sites.
I know people say it has to be served from a fully rendered Phoenix page but I don’t see that limitation in any of the code.
Excited to play around with it.
I happen to have a very good time using LiveView in a number of scenarios, and found the article good enough to be shared.
The conceptual model didn’t work for me. Using client-side frameworks with json over the wire is a simple model. Ideally the server decides where things are rendered.
These are important tech innovations, however the missing piece is still WASM. Being able to write the full-stack in one language. A step further WASM enables is interoperability between languages. Being able to call a Python ML lib client-side from your JS/Ruby/C# would be a game changer.
Sadly, WASM for ruby and Python is not quite there yet.
How is it different from reactive web views? Link below
tldr; since we are built on top of the Phoenix channel primitive, it will have the same scaling characteristics.
https://www.phoenixframework.org/blog/the-road-to-2-million-...