Skip to content

},System.IObservable{System.Boolean})} },System.IObservable{System.Boolean},System.Reactive.Concurrency.IScheduler)} },System.IObservable{System.Boolean},System.Boolean,System.Reactive.Concurrency.IScheduler)} },System.IObservable{System.Boolean},System.Nullable{System.TimeSpan},System.Reactive.Concurrency.IScheduler)} },System.IObservable{System.Boolean},System.Boolean,System.Nullable{System.TimeSpan},System.Reactive.Concurrency.IScheduler)} },System.IObservable{System.Boolean},System.Reactive.Concurrency.IScheduler,System.IObservable{System.Reactive.Unit})} },System.IObservable{System.Boolean},System.Boolean,System.IObservable{System.Reactive.Unit},System.Reactive.Concurrency.IScheduler)}

ObservableCacheEx.BatchIf(IObservable>, IObservable) method

Defined in

Type: ObservableCacheEx Namespace: DynamicData Assembly: DynamicData.dll

Applies to

net10.0, netstandard2.0

Overloads

  1. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector) where TObject : notnull where TKey : notnull

  2. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

  3. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, bool initialPauseState, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

  4. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, TimeSpan? timeOut, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

  5. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, bool initialPauseState, TimeSpan? timeOut, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

  6. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, IScheduler? scheduler = null, IObservable<Unit>? timer = null) where TObject : notnull where TKey : notnull

  7. public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, bool initialPauseState, IObservable<Unit>? timer, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

1. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector) where TObject : notnull where TKey : notnull

View source (opens in a new tab)

Inherited documentation

These docs were inherited from ObservableCacheEx. The member doesn't override them on this type.

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that when true, buffering begins. When false, the buffer is flushed.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

This overload delegates to the primary overload with initialPauseState: false and no scheduler.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also

2. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

View source (opens in a new tab)

Inherited documentation

These docs were inherited from ObservableCacheEx. The member doesn't override them on this type.

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that when true, buffering begins. When false, the buffer is flushed.
scheduler = null[IScheduler?](#The [IScheduler](# for timeout timing.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

This overload delegates to the primary overload with initialPauseState: false.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also

3. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, bool initialPauseState, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

View source (opens in a new tab)

Inherited documentation

These docs were inherited from ObservableCacheEx. The member doesn't override them on this type.

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that when true, buffering begins. When false, the buffer is flushed.
initialPauseStatebool (opens in a new tab)If true, starts in a paused (buffering) state.
scheduler = null[IScheduler?](#The [IScheduler](# for timeout timing.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

This overload delegates to the primary overload with default initialPauseState: false.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also

4. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, TimeSpan? timeOut, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

View source (opens in a new tab)

Inherited documentation

These docs were inherited from ObservableCacheEx. The member doesn't override them on this type.

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that when true, buffering begins. When false, the buffer is flushed.
timeOutTimeSpan? (opens in a new tab)A TimeSpan (opens in a new tab) that maximum time the buffer stays open. When elapsed, the buffer is flushed regardless of pause state.
scheduler = null[IScheduler?](#The [IScheduler](# for timeout timing.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

This overload omits initialPauseState (defaults to false) but accepts a timeout.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also

5. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, bool initialPauseState, TimeSpan? timeOut, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

View source (opens in a new tab)

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that when true, buffering begins. When false, the buffer is flushed.
initialPauseStatebool (opens in a new tab)If true, starts in a paused (buffering) state.
timeOutTimeSpan? (opens in a new tab)A TimeSpan (opens in a new tab) that maximum time the buffer stays open. When elapsed, the buffer is flushed regardless of pause state.
scheduler = null[IScheduler?](#The [IScheduler](# for timeout timing.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

While paused, incoming changesets are accumulated. On resume (or timeout), all buffered changesets are merged into a single changeset and emitted. While not paused, changesets pass through immediately.

EventBehavior
AddBuffered while paused; forwarded immediately while active.
UpdateBuffered while paused; forwarded immediately while active.
RemoveBuffered while paused; forwarded immediately while active.
RefreshBuffered while paused; forwarded immediately while active.
OnErrorBuffered data is lost.
OnCompletedAny remaining buffered data is flushed before completion.

Worth noting: If the source completes while paused, buffered data IS flushed before OnCompleted. However, if the source errors while paused, buffered data is lost.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also

6. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, IScheduler? scheduler = null, IObservable<Unit>? timer = null) where TObject : notnull where TKey : notnull

View source (opens in a new tab)

Inherited documentation

These docs were inherited from ObservableCacheEx. The member doesn't override them on this type.

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that controls buffering: true begins buffering, false flushes the buffer.
scheduler = null[IScheduler?](#An optional [IScheduler](# retained only for source compatibility. It does not schedule any work on this overload: the operator schedules work solely to honour a TimeSpan (opens in a new tab) timeout, and this overload always forwards a null timeout, so the value is unused whether or not timer is supplied. A supplied timer controls its own scheduling. Use [BatchIf](# for scheduler-driven timing.
timer = nullIObservable? (opens in a new tab)An optional IObservable (opens in a new tab) timer. The buffer is flushed each time the timer produces a value, and buffering ceases when it completes.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

This overload starts unpaused. It exists so that a named timer argument, with or without a named scheduler, is a supported call shape without supplying an initial pause state.

The parameter order and the absence of an initialPauseState parameter are both deliberate, and changing either reintroduces a compile error in previously valid code. Declaring scheduler before timer keeps the fourth positional parameter incompatible with IScheduler, so BatchIf(pauseIfTrueSelector, null, scheduler) still binds unambiguously to the TimeSpan (opens in a new tab) timeout overload. Omitting initialPauseState keeps a fully named call that supplies an initial pause state bound unambiguously to the overload that accepts one.

Supply an initial pause state through BatchIf.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also

7. Overload

public static IObservable<IChangeSet<TObject, TKey>> BatchIf<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source, IObservable<bool> pauseIfTrueSelector, bool initialPauseState, IObservable<Unit>? timer, IScheduler? scheduler = null) where TObject : notnull where TKey : notnull

:material-source-branch: View source (opens in a new tab)

Inherited documentation

These docs were inherited from ObservableCacheEx. The member doesn't override them on this type.

Summary: Conditionally buffers changesets while a pause signal is active, then flushes all buffered changes as a single merged changeset when the signal resumes.

Type parameters

NameDescription
TObjectThe type of the object.
TKeyThe type of the key.

Parameters

NameTypeDescription
sourceIObservable> (opens in a new tab)The source IObservable&lt;IChangeSet&lt;TObject, TKey&gt;&gt; to conditionally buffer.
pauseIfTrueSelectorIObservable (opens in a new tab)An IObservable&lt;bool&gt; that controls buffering: true begins buffering, false flushes the buffer.
initialPauseStatebool (opens in a new tab)If true, starts in a paused (buffering) state.
timerIObservable? (opens in a new tab)An optional IObservable (opens in a new tab) timer. The buffer is flushed each time the timer produces a value, and buffering ceases when it completes.
scheduler = null[IScheduler?](#An optional [IScheduler](# for scheduling work.

Returns: IObservable> (opens in a new tab) -- An observable that emits changesets, buffered or passthrough depending on pause state.

Remarks

This overload accepts an explicit timer observable instead of a TimeSpan (opens in a new tab) timeout.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)source or pauseIfTrueSelector is null.

See also