Add 3 new streaming apps with explicit output declarations: - streaming-clock.ds: output hours, minutes, seconds (tick private) - streaming-stats.ds: output total, average, max (sum private) - streaming-mood.ds: output mood, energy, color (clicks private) Add compose-dashboard.ds that receives all 4 streams via unique relay channels (/stream/default, /stream/clock, /stream/stats, /stream/mood) into a single dashboard view. Each app demonstrates selective signal registration — only declared outputs are streamed, internal state remains private.
44 lines
929 B
Text
44 lines
929 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
|
|
click: sum += 5
|
|
}
|
|
button "+10" {
|
|
click: total += 1
|
|
click: sum += 10
|
|
}
|
|
button "+25" {
|
|
click: total += 1
|
|
click: sum += 25
|
|
click: max = 25
|
|
}
|
|
button "+50" {
|
|
click: total += 1
|
|
click: sum += 50
|
|
click: max = 50
|
|
}
|
|
]
|
|
]
|