Class RepeatOperator
Extension methods implementing the repeat operator.
public static class RepeatOperator
- Inheritance
-
System.ObjectRepeatOperator
Remarks
rxjs's repeat accepts either a plain repeat count or a single RepeatConfig object combining
count and delay (a fixed number of milliseconds, or a per-cycle notifier-returning function).
As with RetryOperator, this port splits that one config object into two overloads instead of
introducing a config type: the original Repeat<T>(Observable<T>, int, TimeSpan?, IScheduler?) (count + an optional fixed TimeSpan
delay), and Repeat<T, TNotification>(Observable<T>, Func<int, Observable<TNotification>>, int) (count + a per-cycle notifier-selector delay). rxjs's
RepeatConfig has no resetOnSuccess equivalent — that option only exists on retry, since
repeat has no error/success distinction to reset on.
Methods
Repeat<T>(Observable<T>, int, TimeSpan?, IScheduler?)
Resubscribes to source whenever it completes, up to count times in
total, instead of forwarding the completion downstream. Once the repeat budget is exhausted, completion
is forwarded via OnCompleted as usual. Unlike Retry, an error from source
is never retried — it is forwarded via OnError immediately, ending the sequence.
public static Observable<T> Repeat<T>(this Observable<T> source, int count = null, TimeSpan? delay = null, IScheduler? scheduler = null)
Parameters
sourceObservable<T>The source sequence to repeat on completion.
countintThe total number of times to subscribe to
source. Defaults to int.MaxValue (effectively repeating forever). A value of zero or less returns an already-completed, empty observable without ever subscribing tosource— unlike Retry<T>(Observable<T>, int, TimeSpan?, IScheduler?, bool)'s zero-or-less handling, which still subscribes once.delayTimeSpan?An optional fixed delay to wait before each resubscription. If null (the default), resubscription happens immediately after completion.
schedulerISchedulerThe scheduler used to time
delay, if provided.
Returns
- Observable<T>
An observable that mirrors
source, resubscribing on completion as described above.
Type Parameters
TThe type of values emitted by
source.
Remarks
This overload covers rxjs's RepeatConfig with a plain numeric or omitted delay (or none at
all). For a per-cycle notifier-observable delay, use Repeat<T, TNotification>(Observable<T>, Func<int, Observable<TNotification>>, int) instead.
Repeat<T, TNotification>(Observable<T>, Func<int, Observable<TNotification>>, int)
Resubscribes to source whenever it completes, up to count times in
total, but waits for the observable returned by delaySelector to emit before each
resubscription instead of resubscribing immediately or after a fixed delay.
public static Observable<T> Repeat<T, TNotification>(this Observable<T> source, Func<int, Observable<TNotification>> delaySelector, int count = null)
Parameters
sourceObservable<T>The source sequence to repeat on completion.
delaySelectorFunc<int, Observable<TNotification>>A function, called with the current 1-based cycle count, that returns an observable whose first emission triggers the resubscription.
countintThe total number of times to subscribe to
source. Defaults to int.MaxValue.
Returns
- Observable<T>
An observable that mirrors
source, resubscribing on completion as described above.
Type Parameters
TThe type of values emitted by
source.TNotificationThe element type of the observable returned by
delaySelector; only its emissions/termination matter, not the values themselves.
Remarks
This is the function-based form of rxjs's RepeatConfig.delay. delaySelector is
called with the current 1-based cycle count (how many times source has completed so
far) and must return a notifier observable: its first emission triggers the resubscription, and an early
completion (without ever emitting) completes the whole sequence instead of repeating. If delaySelector
itself throws, or the notifier it returns errors, that exception is forwarded via OnError.