James_E
Phx-error topbar canvas: tell the difference between "loading" and "connecting"?
Whenever there’s a connection error on LiveView, the current version of phx.new sticks a completely fake progress bar at the top of the screen, which fills at the hardcoded rate of 5% of the remaining distance to 95%, each frame, without regard to any actual reconnection progress or post-reconnection sync progress.
I’d like to replace this with a less misleading disconnection indicator, such as an indeterminate progress bar. But I’d also like to (in the event that the latter takes more than 1 frame) switch over to showing a “real” progress bar showing the approximate completion of the actual post-reconnection sync.
So: does Phoenix have any hooks to tell the difference between these? I tried to find it myself, but I couldn’t spot where the existing “page-loading” hooks are coded, so I wasn’t immediately able to just look around at the neighboring code to check.
(I’m not asking about how to program the replacement topbar drawing code as that’s going to be a pretty simple exercise and is entirely out-of-scope of Elixir/Phoenix anyway; I’m only asking how I would hook into LiveView to know when to run which version of the drawing code.)
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 3 of 3 Posts
Hermanverschooten
a grep shows them in
phoenix_live_view/assets/js/phoenix_live_view/live_socket.jsaround line 763.gushonorato
Have you tried to implement a disconnection feedback using lifecycle events?
You can find more information here: Bindings — Phoenix LiveView v1.2.5*
James_E
oh, wow, guess I was looking in the entirely wrong source tree. Thanks for the pointer.
Though it looks like that file just contains a wrapper function… a bit more digging didn’t reveal any obvious hooks into the larger state.
I see, thank you!
I didn’t realize Phoenix really does have a separate set of events for that.
I’m still not sure how to quantify a LiveView resync (for example, is there any interface to check the size of the socket’s queue during reconnect), but this at least allows my app to react differently to a mere loading event that happens to be taking a while vs. a clear disconnect from the LiveView.