stelcodes / nuzzle

A functional static site generator so smol you won't even notice it's there 🐈
Eclipse Public License 2.0
17 stars 1 forks source link

Make server web page content auto-update when content file changes #123

Open stelcodes opened 2 years ago

stelcodes commented 2 years ago

It would be awesome to have a truly hot-reloading web server that updates the web page when the associated content file is modified. I would have to change the ring app to be async I think and use http-kit's support for websockets. Then on the server I could poll the .lastModified time of the content file every second and upon a modification I could send an event to the client JS via WebSocket that contains the full HTML or possibly just the body element. Then the client JS could replace the body tag with the new one from the WebSocket.

I should probably just send a WebSocket message every second from the client to the server to make sure that it's still open. I don't think sending small messages every second would waste that many CPU cycles. I don't want to get into a state where the server is polling the file forever even though the WebSocket is closed. I think the server will have to poll both the file and the client JS.

stelcodes commented 2 years ago

JS Techniques

Use WebSocket API directly

Options

Vanilla JS

Cherry

ClojureScript