Skip to content

Commit

Permalink
chore: Add build times to live reload
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Aug 13, 2023
1 parent 88818b4 commit d7215b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .esbuild/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ function handleFileChange() {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(async () => {
const time = Date.now();
await rebuildAll();
sendEventsToAll();
console.log('Rebuild & Refresh complete in' + (Date.now() - time) + 'ms');
timeoutId = undefined;
}, 100);
}
Expand Down
8 changes: 5 additions & 3 deletions demos/dev/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<title>Mermaid development page</title>
</head>
<body>
<pre class="mermaid">info</pre>

<pre id="diagram" class="mermaid">
graph TB
a --> b
Expand Down Expand Up @@ -44,8 +46,8 @@
location.reload();
}
};
events.onerror = (error) => {
console.error(error);
events.onerror = () => {
// No need to log this error, as it's not useful.
events.close();
// Try to reconnect after 1 second in case of errors
setTimeout(connectToEvents, 1000);
Expand All @@ -55,7 +57,7 @@
};
};
if (liveReload) {
connectToEvents();
setTimeout(connectToEvents, 1000);
}
</script>
</body>
Expand Down

0 comments on commit d7215b2

Please sign in to comment.