TermUI.Widgets.StreamWidget.Consumer (TermUI v0.2.0)

View Source

GenStage 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

Starts a consumer linked to a widget process.

Functions

start_link(widget_pid, opts \\ [])

@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)

subscribe(consumer, producer, opts \\ [])

@spec subscribe(GenServer.server(), GenStage.stage(), keyword()) ::
  {:ok, reference()} | {:error, term()}

Subscribe to a producer.