Class ShareConfig<T>
Configuration object for the Share<T>(Observable<T>, ShareConfig<T>) overload,
mirroring rxjs's ShareConfig. All properties default to rxjs's own defaults
(resetOnError: true, resetOnComplete: true, resetOnRefCountZero: true, plain Subject<T>
connector), so new ShareConfig<T>() behaves identically to the parameterless Share<T>(Observable<T>).
public sealed class ShareConfig<T>
Type Parameters
TThe element type of the observable being shared.
- Inheritance
-
System.ObjectShareConfig<T>
Remarks
Deliberate deviation from rxjs: ResetOnError, ResetOnComplete, and
ResetOnRefCountZero are plain System.Boolean only here. Real rxjs also accepts a notifier
factory ((error?) => ObservableInput<any>) for each, letting the reset be delayed/conditional on
some other observable emitting. That variant is not implemented -- it adds substantial complexity (async/deferred
reset timing, unhandled-error-on-notifier-error semantics) for a corner of the API this port's target use case
(Puppeteer-style retry/timeout combinators) never needs. ShareCore already carried this
same "boolean case only" note for the completion knob before this config object existed; it now applies
uniformly to all three reset knobs.
Properties
Connector
Factory used to create the Subject<T>-like connector that multicasts the source to
subscribers. Defaults to a plain Subject<T> (matches rxjs's default). Pass e.g.
() => new BehaviorSubject<T>(initialValue) to get "replay the latest value" semantics
with configurable reset behavior -- ShareReplay<T>(Observable<T>, int) already covers the
dedicated ReplaySubject<T>-backed caching case, so this knob's main remaining value is
exactly this: other connector types (BehaviorSubject<T>, AsyncSubject<T>, or a
caller's own Subject<T> subclass) that don't have their own dedicated Share* operator.
public Func<Subject<T>>? Connector { get; set; }
Property Value
- Func<Subject<T>>?
ResetOnComplete
If true (the default), the source completing resets the internal state back to "cold" -- a later subscriber gets a fresh connector and a fresh subscription to the source. If false, completion is pushed into the connector and the connector is kept: subsequent subscribers attach to that same, now-completed connector and immediately receive completion, and the source is never resubscribed.
public bool ResetOnComplete { get; set; }
Property Value
- bool
ResetOnError
If true (the default), an error from the source resets the internal state back to "cold" -- a later subscriber gets a fresh connector and a fresh subscription to the source. If false, the error is pushed into the connector and the connector is kept: subsequent subscribers attach to that same, now-errored connector and immediately receive the same error, and the source is never resubscribed.
public bool ResetOnError { get; set; }
Property Value
- bool
ResetOnRefCountZero
If true (the default), the subscriber count dropping back to zero (purely from unsubscription, not from the source erroring/completing) resets the internal state: the source subscription is torn down, and a later subscriber reconnects from scratch. If false, the source subscription is kept alive with nobody listening, so a later subscriber reattaches to the same connector and the same still-live source subscription instead of resubscribing.
public bool ResetOnRefCountZero { get; set; }
Property Value
- bool