dreamstack/examples/compose-widgets.ds
enzotar b0e7de3b2e fix: signal composition — stream derived signals, fix identity check, correct relay routing
- Register derived signals in _signalRegistry so _streamSync includes them
- Auto-sync all signals (source + derived) after flush() recomputes effects
- Fix Object.assign identity check: create new object so signal setter detects changes
- Change _connectStream receiver path from /signal/main to /stream/default
- Initialize stream state with {} instead of null to prevent crashes
- Emit StreamFrom bindings directly without double-wrapping in signal()

Verified: static build shows Count: 9, Doubled: 18 on composition page.
HMR interference with WebSocket connections is a separate issue.
2026-02-25 23:55:05 -08:00

28 lines
812 B
Text

-- DreamStack Signal Composition Demo
-- Compose two independent widget streams into one dashboard.
--
-- Run with:
-- Tab 1: dreamstack stream examples/streaming-counter.ds
-- Tab 2: dreamstack stream examples/streaming-physics.ds --port 9101
-- Tab 3: dreamstack dev examples/compose-widgets.ds --port 3001
--
-- Open http://localhost:3001 to see both streams composed.
let counter = stream from "ws://localhost:9100"
let physics = stream from "ws://localhost:9101"
view main =
column [
text "📡 Composed Dashboard"
row [
column [
text "── Counter Widget ──"
text "Count: {counter.count}"
text "Doubled: {counter.doubled}"
]
column [
text "── Physics Widget ──"
text "Bodies: {physics.body_count}"
]
]
]