Documentation
¶
Overview ¶
Package stream bridges provider event channels to Bubble Tea commands.
Providers emit events on a <-chan provider.Event channel. Bubble Tea requires commands (tea.Cmd) that return tea.Msg values. This package provides the glue between the two.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrainToString ¶
DrainToString reads all events from a channel synchronously and returns the concatenated text. Used by one-shot CLI mode where no TUI is running. Returns the full response and the first error encountered (if any).
func NextEvent ¶
NextEvent returns a tea.Cmd that reads one event from the channel and converts it to the appropriate tea.Msg.
The returned Cmd should be chained: after handling a TokenMsg, schedule another NextEvent() to read the next token. Stop chaining on DoneMsg or ErrorMsg.
Usage in your Update():
case stream.TokenMsg:
m.response += msg.Content
return m, stream.NextEvent(m.eventChan)
case stream.DoneMsg:
// done — don't chain
case stream.ErrorMsg:
// handle error — don't chain
Types ¶
type ErrorMsg ¶
type ErrorMsg struct {
Err error
}
ErrorMsg carries an error from the provider stream.