• Wrap a source to allow multiple subscribers to the same underlying stream

    The input source will be susbcribed when the output has at least one subscriber, and unsubscribed when the output has no subscribers. The input will be paused when any subscriber pauses, and will only be resumed when all subscribers are unpaused. All subscribers are closed or thrown if the input source closes or throws.

    (Generally speaking, you should place the share call as late in your pipelines as possible, if you use it at all. It adds some overhead that is wasted if the stream doesn't have multiple subscribers, and may be redundant if an upstream source is already shared. It's mainly useful if there is a lot of mapping, filtering, or other complicated processing taking place upstream of the share, and you know for a fact there will be enough subscribers to make it a bottleneck. You should probably also consider putting some slack() either upstream or downstream of the share, if the upstream supports backpressure.)

    Type Parameters

    • T

    Parameters

    Returns Source<T>