Turbo drive page reload on backend changes. #385
mtomov
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, vite does a full page refresh when receiving a
full-reload
websocket message from the server. This has a jarring effect on the page, as it needs to wait for the JS to load, etc..I was thinking if we could use Turbo to just bring the new html in, and replace the body instead of
location.reload()
.Managed to get it working, and our team has been using for a few weeks now. You could even use it when making changes to
.rb
models, such as components. Just configure the file patterns using the FullReload plugin.Add to your main entrypoint, such as
application.js
I thought I need to add a
setTimeout
aroundTurbo.visit
to give templates time to regenerate, but after removing it, it still seems to work.Would love to wrap this in a plugin. I took a look at the documentation, and it seems like I'd need to use
transform
to add this additional frontend code to one of the files. If anyone has something more concrete as a base, would be interested to learn.Beta Was this translation helpful? Give feedback.
All reactions