A Counter with websockets
This counter should increment every 3 seconds.
Counter
here
Here is what the html above looks like:
Here are some things to notice. The websocket connection is made
immediately after the page loads. Every time the page is reloaded,
the counter starts up again at 0. The first response sent through
the websocket appears below, and is wrapped in
<div data-hx-swap-oob="innerHtml:#ws-response">
After that, every 3 seconds we send:
<span data-hx-swap-oob="innerHTML:#counter">1</span>
through the socket, which replaces the counter with an
incrementing integer.