LiveView disconnect handling

Hi all,

We are considering to use LiveView in a next project and the question came up about unstable internet connection and how LiveView handles it.

As I remember from @chrismccord presentation, the LiveView area would have an overlay until the connection was restored. For our use-case we want to create a form in a LiveView and it would be inconvenient if in the middle of the form it would be disabled by an overlay. Is there a flexible way to handle it? Maybe I just want to disable the submit button and show a message under it that the user should wait for connection to restore.

Also is there a best practice already how not to lose data entered in the form if a disconnect happens? localStorage?

Hi @egze,

I think that handling the situation you describe is a work in progress for the liveview team. There is some discussion towards the end of this thread: New questions about LiveView based on Chris' keynote from ElixirConf 2019, and the following discusses a related issue: https://github.com/phoenixframework/phoenix_live_view/issues/278 (which includes an example on how to reapply client side form state to the liveview on reconnection).

1 Like

Thanks. Good to know that it is being worked on.

Sorry to resurrect this old thread, but this feels like the most relevant topic.

On poor connections, the default LiveView behavior can be pretty frustrating for me: a page that requires no interaction with the server will lock down and prevent scrolling/interaction until the socket connection is restored. I know I can easily change this by tweaking the behavior of the overlay, but then I can get into the situation where the user attempts a server interaction while in an offline state.

Is there a good way to permit the user to scroll and interact with a page, and lock down the page when they attempt something that requires a server call?