TermUI.Widgets.StreamWidget.Consumer (TermUI v1.0.0)
View SourceGenStage consumer for StreamWidget.
This module provides a GenStage consumer that forwards events to a process as
{:stream_items, events}. GenStage manages subscription demand; this adapter
does not dynamically change demand from the widget's buffer occupancy.
With an embedded widget, pass the runtime/root PID and forward received
messages from the root's optional handle_info/2 to the stream widget's
state callback.
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- Retained metadata (default: 10); usemax_demandandmin_demandinsubscribe/3to control the actual subscription
@spec subscribe(GenServer.server(), GenStage.stage(), keyword()) :: {:ok, reference()} | {:error, term()}
Subscribe to a producer.