transferum
    Preparing search index...

    Class DuplexPipelineBuilder<TCurrent, TStartTransfer>

    Use CompositeTransferBuilder instead. Will be removed in the next major release.

    Builder for constructing full-duplex pipelines (DuplexPipeline).

    Purpose: Creates a composite transfer with a duplex interface (DuplexCompositeTransfer), which supports both input (push) and output (pull/subscribe) operations.

    Pipeline structure: TStartTransfer [-> DuplexTransfer -> ... ->] -> TFinishTransfer │ │ │ └─ start() └─ to() └─ finish()

    Where:

    • TStartTransfer — initial duplex transfer (must be InputTransfer)
    • DuplexTransfer — intermediate chain links (optional, via to())
    • TFinishTransfer — final output transfer (OutputTransfer)

    Mechanics:

    1. start(startTransfer) — creates a builder with the initial duplex transfer
    2. to(nextTransfer, owned?) — adds an intermediate duplex transfer to the chain, linking it to the previous one via linkTransfers()
    3. finish(lastTransfer, options?) — completes the pipeline, creating a UniversalCompositeTransfer

    finish() options:

    • triggerable?: TriggerableInterface — explicit trigger for the composite
    • gate?: GateInterface — explicit gate for flow control
    • owned?: boolean — whether to destroy lastTransfer on composite destroy()

    The owned parameter in to():

    • owned = true — the intermediate transfer is added to the owned resources array and will be destroyed on composite destroy()
    • owned = false (default) — the transfer is not destroyed automatically

    Data types:

    • Composite input type = InputTransferDataType
    • Composite output type = OutputTransferDataType

    Use cases:

    • Building a bidirectional data processing pipeline
    • Data transformation with both push and pull operations
    • Creating intermediate nodes for complex pipeline architectures
    const pipeline = DuplexPipelineBuilder
    .start(new PushStoredChannelTransfer<number>())
    .to(new ConditionTransfer<number>(x => x > 0))
    .to(new PushStoredChannelTransfer<number>())
    .finish(new PushStoredChannelTransfer<number>(), {
    owned: true
    });

    // Push data
    pipeline.push(42);

    // Subscribe to output data
    pipeline.subscribe(data => console.log(data));

    // Pull data
    const value = pipeline.pull();

    pipeline.destroy();

    Type Parameters

    • TCurrent

      — data type of the current chain link

    • TStartTransfer extends InputTransfer<unknown>

      — type of the initial transfer (must be InputTransfer)

    Implements

    Index