dreamstack/examples/streaming-stats.ds
enzotar c47852957f fix: merge duplicate click props + upgrade streaming examples
- Duplicate prop keys now merge into Block expressions
  click: a then click: b → Block([a, b])
- All actions fire in one click (was silently overwriting)
- streaming-mood.ds upgraded to semicolons
- streaming-stats.ds upgraded to semicolons
- Browser-verified: Happy button fires 3 actions (mood+color+energy)
- All 7 examples pass regression
2026-02-26 17:44:21 -08:00

30 lines
789 B
Text

-- DreamStack Streaming Stats
-- Tracks button presses and computes statistics.
-- Only total, average, max are exposed (sum and last_sample are internal).
--
-- Run with:
-- dreamstack stream examples/streaming-stats.ds --port 3003
let total = 0
let max = 0
let sum = 0
let average = sum / (total + 1)
stream stats on "ws://localhost:9100/peer/stats" {
mode: signal,
output: total, average, max
}
view stats =
column [
text "📊 Streaming Stats"
text "Samples: {total}"
text "Average: {average}"
text "Max: {max}"
row [
button "+5" { click: total += 1; sum += 5 }
button "+10" { click: total += 1; sum += 10 }
button "+25" { click: total += 1; sum += 25; max = 25 }
button "+50" { click: total += 1; sum += 50; max = 50 }
]
]