Phoenix LiveView vs SPA

Sure, I’ll try!

ProseMirror maintains it’s own internal state and rendering of that state. This is great, but in LiveView you now need some way of sending this state to the server. And since this internal state is relatively complex, you would probably not want to serialize the whole data model on every keyDown event and send it over the websocket.

That is not to say it is impossible, it is just not ergonomic and obvious in that you have to think about setting up a hook, think about when to send data to the server and think about reloading situations in which you may loose data.

In a single page application you typically have a local application state to begin with, so you have to deal with these problems from the start. That’s why you have established, well understood patterns on how to deal with these situations in SPAs. On the other hand: this extra layer makes everything much more complex and this is precisely why LiveView will typically be faster to develop with.

In summary: Depending on your situation, you cannot escape maintaining application state purely in the frontend. In these scenarios LiveView might, or might not, be a good pick for you and your team.

4 Likes