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

htmx sse #1

Closed
gedw99 opened this issue Dec 2, 2024 · 4 comments
Closed

htmx sse #1

gedw99 opened this issue Dec 2, 2024 · 4 comments

Comments

@gedw99
Copy link

gedw99 commented Dec 2, 2024

nice proof of concept.

so web screens update without a refresh also. htmx sse is good for this.

https://github.com/bigskysoftware/htmx-extensions/blob/main/src/sse/sse.js

@headblockhead
Copy link
Owner

Thanks! I'll look into this.

@gedw99
Copy link
Author

gedw99 commented Dec 2, 2024

you might find this interesting.

maddalax/htmgo#52

htmgo a htmx golang system, with that code generates the Router and a few other bits. It's using SSE too.

The Issue is talking about compiling to WASM, which of course is what you do, compiling to WASM for Cloud Flare.

The reason I am talking about this link is because I think I can adapt the HTMGO code gen so that it works with github.com/syumai/workers, just like you have.

@headblockhead
Copy link
Owner

headblockhead commented Dec 3, 2024

In regard to the issue you linked, it sounds like an interesting idea! Dependencies not compiling to WASM is a pretty huge issue at the moment, many libraries I have tried to import failed to build, or worse failed at runtime when running in webassembly. :(

This project uses tinygo to build for WASM as it helps reduce the size of the output binary, but many built-in Go features are not implemented on TinyGo, and vice versa. It's a tricky balancing act.

On adding SSE,
I made a very simple SSE implementation, now live. There is no way to subscribe to KV updates as far as I'm aware, and using a channel to send events didn't work with the cloudflare runners when I tried, so my solution polls the KV store every 0.5 seconds. The free tier has 100,000 requests/day and 1000 requests/min as limits, so it should be fine.

The main issue I had when building it was that every guide instructs you to use w.(http.Flusher).Flush() to ensure your event is sent, but that mysteriously crashes the WASM worker when called.

I hope this may be of help to you! Thanks for taking the time to write an issue and response.

@gedw99
Copy link
Author

gedw99 commented Dec 4, 2024

Totally know what you mean about the “ flushing “. Polling is the only solution , but let me have a look . Have 2 other ideas for where the actor lives ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants