richardanaya / wasm-service

HTMX, WebAssembly, Rust, ServiceWorkers
MIT License
696 stars 31 forks source link

Use html! macro and matchit router #4

Closed infogulch closed 2 years ago

infogulch commented 2 years ago

This makes it nice to write html as a collection of reusable htmx component rust functions.

Also:


Things I'd like to do next, in no particular order:

  1. Make demo slightly more interesting (a todo app?). Probably use htmx.org example as reference.
  2. Make html! macro return impl trait Read instead of String to eliminate copying during document response construction
  3. Factor the code and add another target to run the same app definition at the origin server as well as a service worker, instead of using some other http server like caddy to serve the initial files.
  4. Investigate different [de]serialization strategies for the http requests
richardanaya commented 2 years ago

All of these sound really great. Matching examples from htmx and todo all seem like very nice traditional examples I've seen. To humbly offer some information I've heard murmurings that tokio might be able to run in WebAssembly in a next version, maybe that's useful as a path for service and server side?

infogulch commented 2 years ago

Using tokio might be interesting for the server side, but I'm not sure if you'd want to expose that in the wasm worker because you'd have to thread rust futures through to js promises. This may have to happen anyway at some point if you want the wasm app service worker to connect to a backend/db but I suspect that will be a pretty big jump in effort. Something to look out for though.

I actually like how simple this project's tooling is in that it doesn't require wasm-bindgen, which might become a thing if you use tokio. Several of the html! macro crates actually require wasm bindgen and expect live access to a DOM like a SPA, I'm glad I avoided that outcome with this syn-rsx crate.

richardanaya commented 2 years ago

Awesome, yah I saw that crate, simplicity is good!