What is the usecases for using live view

I have read and try with some live view example, and I saw that the UI is quite lagging.
When I click a button, it does not response immediately. Depend on my connection, I might wait for a second to see the result.
I wonder what is live view best suited for?

LiveView: Use cases

1 Like

What kind of example are you building? Does your server log show any errors? The only time I don’t see an immediate update is if the event wasn’t handled properly and the LiveView process crashed.

Do you mean when you download & run examples locally, or are you checking out examples online?

If you’re running them on your own machine there should be no lag (unless it’s a particularly extravagant example app). If there is, then I would post some more details because it’s definitely an unexpected problem.

If however it’s online examples you’re referring to, then there could be a latency problems depending on where you are in relation to the app hosting provider. I’m in Australia, and can easily get round-trip latencies of 1s or more to Europe. And demo apps in particular are probably not replicated across multiple datacentres, so could be distant from your location.

I’m using fly.io for projects I’m playing with, and it becomes very obvious as I play with shifting test apps between locations how developers need to be aware of the location of users vis a vis the app host. It’s a tradeoff with LiveView’s fundamentally simpler programming model vs the (potential) location-neutrality of full javascript front ends.

2 Likes

Having business logic on both the frontend and the backend sucks. It then becomes a distributed system and you need to deal with all the temporary inconsistency between the 2 sides.

  • If you can get away with a very dumb backend and put all your business logic in the frontend, then by all means do it.
  • If your backend logic is complex, LiveView gives you a way to dumb down the frontend considerably, so you are back in the comfort zone of none-distributed system.
  • If your system absolutely demand complexity on both side, I pity you and LV cannot help you.
2 Likes

LiveView is an obvious choice to replace JS that interacts with your server. There is already latency and because of all the LiveView optimizations, the overall performance may be better.

Using LiveView to replace JS that doesn’t interact with your server will introduce latency, which may or may not be an issue depending on your use case.

You could also use it to replace JS that interacts with somebody else’s server, assuming you can call their server from your server.

I mean when I click a button and it has to send back to server, handle the event, return data then render to user.
I will be slow if my connection is not stable

I understand the trade off. I intended to build an web app to manage inventory.
I play with https://adoptoposs.org/ and I think it’s not really smooth.
So I do not risk building it using LiveView.
I’m asking to see if I can apply LiveView to any part of our system.