Examples menu

๐Ÿ“ˆ Stock Ticker

Real-time stock price simulation with live chart updates every 2 seconds.

Simulated market data updates every 2 seconds via a server-side OpenSwoole timer. Prices drift randomly and history is tracked for each symbol.
ROUTE scope on the dashboard means all viewers share the same rendered output. Per-stock detail pages use custom scopes so each symbol updates independently.
Lazy timers โ€” the price ticker only runs while at least one client is connected. Zero viewers means zero CPU cost.
Deep linking โ€” each stock has its own URL (/stock/{symbol}). Navigate directly to a ticker or click through from the dashboard.
Signal-driven charts on detail pages. Price history is stored in signals so the chart data updates live without re-rendering the entire page.
Apache ECharts renders sparklines on the dashboard and the full chart on detail pages. The chart library receives updated data via Datastar signals โ€” no manual JS refresh needed.

โšก Signals

price string Custom

Current formatted price for a stock symbol. Custom scope per symbol.

times array Custom

Timestamp array for the price history chart.

prices array Custom

Price array for the chart. Updated every 2 seconds by the server timer.

๐Ÿ‘ Views

stock_dashboard.html.twig

ROUTE-scoped dashboard with sparklines for all 8 stocks. Shared by all viewers.

stock_detail.html.twig

Per-symbol detail page with full ECharts chart. Custom scope per stock symbol.

stock_not_found.html.twig

Fallback for unknown stock symbols.