TermUI.Widgets.StreamWidget.Consumer (TermUI v0.2.0)
View SourceGenStage consumer for StreamWidget.
This module provides a GenStage consumer that forwards events to a StreamWidget. It handles backpressure by managing demand based on the widget's buffer state.
Usage
# Start the consumer linked to a widget process
{:ok, consumer} = StreamWidget.Consumer.start_link(widget_pid)
# Subscribe to a producer
GenStage.sync_subscribe(consumer, to: producer)
# Or subscribe with options
GenStage.sync_subscribe(consumer, to: producer, max_demand: 100, min_demand: 50)
Summary
Functions
@spec start_link( pid(), keyword() ) :: GenServer.on_start()
Starts a consumer linked to a widget process.
Options
:demand- How many items to request at a time (default: 10)
@spec subscribe(GenServer.server(), GenStage.stage(), keyword()) :: {:ok, reference()} | {:error, term()}
Subscribe to a producer.