feat(examples): add streaming .ds examples — compiler-native streaming
- streaming-counter.ds: reactive counter with 'stream counter on ws://...' - streaming-receiver.ds: remote receiver with 'stream from ws://...' - E2E verified: compiles to streaming JS, connects to relay, sends signal diffs
This commit is contained in:
parent
2fec039a28
commit
be811662bf
2 changed files with 41 additions and 0 deletions
26
examples/streaming-counter.ds
Normal file
26
examples/streaming-counter.ds
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- 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"
|
||||
|
||||
stream counter on "ws://localhost:9100" { mode: signal }
|
||||
|
||||
view counter =
|
||||
column [
|
||||
text message
|
||||
text count
|
||||
text doubled
|
||||
row [
|
||||
button "-" { click: count -= 1 }
|
||||
button "+" { click: count += 1 }
|
||||
]
|
||||
when count > 10 ->
|
||||
text "On fire!"
|
||||
]
|
||||
15
examples/streaming-receiver.ds
Normal file
15
examples/streaming-receiver.ds
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- DreamStack Streaming Receiver
|
||||
-- Connects to a remote stream and renders the received signal state.
|
||||
--
|
||||
-- Run with:
|
||||
-- (source must be running first)
|
||||
-- dreamstack dev examples/streaming-receiver.ds --port 3001
|
||||
|
||||
let remote = stream from "ws://localhost:9100"
|
||||
|
||||
view main =
|
||||
column [
|
||||
text "📡 Remote Stream"
|
||||
text "Count: {remote.count}"
|
||||
text "Doubled: {remote.doubled}"
|
||||
]
|
||||
Loading…
Add table
Reference in a new issue