Class ExpandOperator
Extension methods implementing the expand operator.
public static class ExpandOperator
- Inheritance
-
System.ObjectExpandOperator
Remarks
Like MergeMapOperator, this port always merges with unbounded concurrency: there is no
concurrent limit parameter, since Puppeteer's own usage (the motivating consumer of this port) never
needs to cap in-flight inner subscriptions. Unlike MergeMap, an unbounded concurrency limit is arguably
more important to flag here: a project that never returns an empty/completing-without-emitting
observable recurses forever, and — since C# gives no bottom type — project's return type must be
Observable<T> (the same as the source), so it is easy to write an accidentally-infinite expansion.
Rely on a downstream operator like Take to cut it off, exactly as rxjs's own documentation examples do.
Methods
Expand<T>(Observable<T>, Func<T, Observable<T>>)
Recursively projects each value — from source itself, and then from every inner
observable project produces — back through project, merging every
resulting inner observable into the output.
public static Observable<T> Expand<T>(this Observable<T> source, Func<T, Observable<T>> project)
Parameters
sourceObservable<T>The source sequence.
projectFunc<T, Observable<T>>A function that maps each value (from the source or from a previous expansion) to an inner observable to expand further.
Returns
- Observable<T>
An observable that emits every value encountered while recursively expanding
source.
Type Parameters
TThe type of values emitted by
source, by every inner observable, and by the output.
Remarks
See the indexed overload for the full behavior description.
Expand<T>(Observable<T>, Func<T, int, Observable<T>>)
Recursively projects each value — from source itself, and then from every inner
observable project produces — along with its zero-based expansion index, back through
project, merging every resulting inner observable into the output.
public static Observable<T> Expand<T>(this Observable<T> source, Func<T, int, Observable<T>> project)
Parameters
sourceObservable<T>The source sequence.
projectFunc<T, int, Observable<T>>A function that maps each value and its expansion index (starting at 0) to an inner observable to expand further.
Returns
- Observable<T>
An observable that emits every value encountered while recursively expanding
source.
Type Parameters
TThe type of values emitted by
source, by every inner observable, and by the output.
Remarks
Every value seen — whether it came directly from source or from a previously projected
inner observable — is immediately forwarded to the output, and is also passed to project
to produce a further inner observable to merge in (which is itself expanded the same way, recursively).
The output completes once source has completed and every inner observable produced,
directly or recursively, has also completed. If project throws, or any inner
observable errors, the exception is forwarded to the subscriber via OnError instead of propagating
synchronously.