Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stelcodes opened this issue Aug 19, 2022 · 1 comment
Open
Labels
enhancement New feature or request hammock time

Comments

@stelcodes
Copy link
Owner

stelcodes commented Aug 19, 2022

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 stelcodes added enhancement New feature or request hammock time labels Aug 19, 2022
@stelcodes
Copy link
Owner Author

stelcodes commented Aug 19, 2022

JS Techniques

Use WebSocket API directly

Options

Vanilla JS

  • Could just slurp from .js file
  • Simplest, probably should start here

Cherry

ClojureScript

  • Possibly overkill
  • Professionally useful maybe?

@stelcodes stelcodes changed the title Make server web page auto-update in real time like MarkdownPreview Make server web page content auto-update when content file changes Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hammock time
Projects
None yet
Development

No branches or pull requests

1 participant