Skip to content

Commit

Permalink
fix: close SSE endpoint when browser page is reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Aug 1, 2024
1 parent a48e910 commit 889c833
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.753
0.2.754
3 changes: 2 additions & 1 deletion cmd/templ/generatecmd/proxy/script.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(function () {
(function() {
let templ_reloadSrc = window.templ_reloadSrc || new EventSource("/_templ/reload/events");
templ_reloadSrc.onmessage = (event) => {
if (event && event.data === "reload") {
window.location.reload();
}
};
window.templ_reloadSrc = templ_reloadSrc;
window.onbeforeunload = () => window.templ_reloadSrc.close();
})();

0 comments on commit 889c833

Please sign in to comment.