2026-02-25 14:34:41 -08:00
|
|
|
-- DreamStack Streaming Counter
|
|
|
|
|
-- A reactive counter that streams all signal changes
|
|
|
|
|
-- to remote receivers via the bitstream relay.
|
|
|
|
|
--
|
|
|
|
|
-- Run with:
|
|
|
|
|
-- cargo run -p ds-stream &
|
|
|
|
|
-- dreamstack stream examples/streaming-counter.ds
|
|
|
|
|
|
|
|
|
|
let count = 0
|
|
|
|
|
let doubled = count * 2
|
|
|
|
|
let message = "Streaming Counter"
|
|
|
|
|
|
2026-02-26 09:45:07 -08:00
|
|
|
stream counter on "ws://localhost:9100/peer/counter" { mode: signal, output: count, doubled }
|
2026-02-25 14:34:41 -08:00
|
|
|
|
|
|
|
|
view counter =
|
|
|
|
|
column [
|
|
|
|
|
text message
|
|
|
|
|
text count
|
|
|
|
|
text doubled
|
|
|
|
|
row [
|
|
|
|
|
button "-" { click: count -= 1 }
|
|
|
|
|
button "+" { click: count += 1 }
|
|
|
|
|
]
|
|
|
|
|
when count > 10 ->
|
|
|
|
|
text "On fire!"
|
|
|
|
|
]
|