dreamstack/examples/streaming-mood.ds
enzotar 8775860fdd feat: 4-app signal composition demo with explicit outputs
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.
2026-02-26 09:04:22 -08:00

50 lines
1.1 KiB
Text

-- DreamStack Streaming Mood
-- Interactive mood and energy tracker.
-- Only mood, energy, color are exposed (clicks is internal).
--
-- Run with:
-- dreamstack stream examples/streaming-mood.ds --port 3004 --relay ws://localhost:9100/source/mood
let mood = "neutral"
let energy = 50
let color = "gray"
let clicks = 0
stream mood_tracker on "ws://localhost:9100/peer/mood" {
mode: signal,
output: mood, energy, color
}
view mood_tracker =
column [
text "😊 Mood Tracker"
text "Mood: {mood}"
text "Energy: {energy}%"
text "Color: {color}"
row [
button "😄 Happy" {
click: mood = "happy"
click: color = "green"
click: energy = energy + 10
}
button "😐 Neutral" {
click: mood = "neutral"
click: color = "gray"
}
button "😤 Angry" {
click: mood = "angry"
click: color = "red"
click: energy = energy - 10
}
]
row [
button "☕ Caffeine" {
click: energy = energy + 25
click: clicks += 1
}
button "😴 Rest" {
click: energy = energy - 15
click: clicks += 1
}
]
]