feat: don't insert proxy reload script on datastar initiated requests#1235
feat: don't insert proxy reload script on datastar initiated requests#1235
Conversation
|
@delaneyj - can you verify this is correct please? My understanding is that there's no need to insert a reload script for live reload (during watch mode) for datastar initiated requests, especially since they're likely to be fragments. This came up in a conversation in Slack. |
|
I have no idea, I never use the templ proxy as I don't have the need. I use a Taskfile task templ:
env:
TEMPL_EXPERIMENT: rawgo
# deps:
# - library
generates:
- "**/*_templ.go"
sources:
- "**/*.templ"
cmds:
- templ generate .a shared page setup... <body>
if site.Env.IsDev {
<div id="hotreload" data-on-load="@get('/hotreload', {retryMaxCount: 1000,retryInterval:20, retryMaxWaitMs:200})"></div>
}
{ children... }
if site.Env.IsDev {
<datastar-inspector></datastar-inspector>
}
</body>and a Go route... var hotReloadOnlyOnce sync.Once
router.Get("/hotreload", func(w http.ResponseWriter, r *http.Request) {
sse := datastar.NewSSE(w, r)
hotReloadOnlyOnce.Do(func() {
sse.ExecuteScript("window.location.reload()")
})
<-r.Context().Done()
})That way I get auto loading of anything from css, images, go, etc so my frontend and backend are always in sync. If there is something specific you need please let me know but I don't think Datastar needs the proxy at all given the builtin SSE support with auto reconnect. |
|
Thanks @delaneyj - hope all is well with you and family by the way! |
You as well! Would be nice to catch up when you have time! |
No description provided.