octoberswimmer / masc

Build browser applications in Go using The Elm Architecture (crossbreed of bubble tea and vecty)
Other
1 stars 0 forks source link

update browser when WasmServer recompiles the code on the backend #2

Open gedw99 opened 4 months ago

gedw99 commented 4 months ago

wonderful stuff and thank you for this.

I ran the example TODO with wasmserve and the first thing I wanted was for the Browser to update automagically.

I wonder if we can send a signal to the wasm running in the browser to force the GUI to update ?


also been playing with https://github.com/tractordev/wanix and figured you might be interested too.

It's a shell and FS inside the browser. All golang and wasm.

It feel like mass and wanix are synergistic. wanix as the OS and mass are the rendering engine.

Let me know what you think :)

cwarden commented 4 months ago

Any thoughts on how we should maintain state across reloads?

gedw99 commented 4 months ago

Any thoughts on how we should maintain state across reloads?

It really depends on the objectives of the project and where you want the state to live.

One way is to use NATS Jetstream which is reactive, so many clients get updated on a single state change.

Server: https://github.com/nats-io/nats-server Client: https://github.com/nats-io/nats.go compiles to WASM.

Then from there it is possible to trigger updates at the many levels of granularity that are needed. Even the Props via the NATS KV store.

  1. On WASM binary change, sent event to Client, and it does full reload.
  2. On user data state change, NATS can automatically trigger state updates to the Client and so the client can re-render the "views" linked to that golang struct state.

You can also just use a SSE Proxy and so then there is no need to import NATS.go to the client wasm.