How to use StreamedMarkdownView for streaming content
mainFor chat-style UIs where the Markdown source grows over time, use StreamedMarkdownView. It requires a StreamedMarkdownSource object. The text property of the source must yield progressively larger snapshots of the full Markdown source (not deltas) via an AsyncStream<String>.
import SwiftUI
import SwiftStreamingMarkdown
class ChatResponseSource: ObservableObject, StreamedMarkdownSource {
var text: AsyncStream<String> { /* yields full source snapshots */ }
}
struct ChatBubble: View {
@EnvironmentObject var source: ChatResponseSource
var body: some View {
StreamedMarkdownView(source: source)
}
}