Skip to main content

Multiple Streams

Real applications often need to stream multiple pieces of content simultaneously. A code reviewer might display issues, suggestions, and improved code in separate panels. A research assistant might summarize multiple sources before synthesizing them. Idyllic supports these patterns through multiple stream<T> fields, each operating independently.

Defining Multiple Stream Fields

Declare multiple stream<T> fields. Each maintains its own value, status, and update history:
Every append() call broadcasts to all connected clients. The framework handles multiplexing automatically.

Sequential Streaming

Complete one stream before starting the next. Works when later streams depend on earlier content:
Each section finishes before the next begins, creating predictable reading flow.

Parallel Streaming

When streams are independent, update them simultaneously with Promise.all:
Clients see multiple cards streaming simultaneously. Fast sources don’t block slow ones.

Client-Side Rendering

Iterate over streams, showing status for each:

FAQ

How many streams can run in parallel?

No hard limit. Practical constraints are LLM rate limits and client rendering performance. Ten simultaneous streams work fine.

What if one parallel stream fails?

With Promise.all, one failure rejects the group. Use Promise.allSettled for independent error handling:

How do I show overall progress?

Track completion count in state:
Client can show “3 of 5 sources analyzed.”