Skip to content

,System.IObservable{--0},System.IObservable{--0})} ,System.IObservable{--0})} ,System.IObservable{--0},System.Reactive.Concurrency.IScheduler)}

Observable.If(Func, IObservable, IObservable) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  • 2. public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource)
  • 3. public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource, IScheduler scheduler)

1. Overload

public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)

Summary: If the specified condition evaluates true, select the thenSource sequence. Otherwise, select the elseSource sequence.

Type parameters

NameDescription
TResultThe type of the elements in the result sequence.

Parameters

NameTypeDescription
conditionFuncCondition evaluated to decide which sequence to return.
thenSourceIObservableSequence returned in case condition evaluates true.
elseSourceIObservableSequence returned in case condition evaluates false.

Returns: IObservable -- thenSource if condition evaluates true; elseSource otherwise.

Exceptions

TypeCondition
System.ArgumentNullExceptioncondition or thenSource or elseSource is null.

2. Overload

public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource)

Summary: If the specified condition evaluates true, select the thenSource sequence. Otherwise, return an empty sequence.

Type parameters

NameDescription
TResultThe type of the elements in the result sequence.

Parameters

NameTypeDescription
conditionFuncCondition evaluated to decide which sequence to return.
thenSourceIObservableSequence returned in case condition evaluates true.

Returns: IObservable -- thenSource if condition evaluates true; an empty sequence otherwise.

Exceptions

TypeCondition
System.ArgumentNullExceptioncondition or thenSource is null.

3. Overload

public static IObservable<TResult> If<TResult>(Func<bool> condition, IObservable<TResult> thenSource, IScheduler scheduler)

Summary: If the specified condition evaluates true, select the thenSource sequence. Otherwise, return an empty sequence generated on the specified scheduler.

Type parameters

NameDescription
TResultThe type of the elements in the result sequence.

Parameters

NameTypeDescription
conditionFuncCondition evaluated to decide which sequence to return.
thenSourceIObservableSequence returned in case condition evaluates true.
scheduler[IScheduler](#Scheduler to generate an empty sequence on in case condition evaluates false.

Returns: IObservable -- thenSource if condition evaluates true; an empty sequence otherwise.

Exceptions

TypeCondition
System.ArgumentNullExceptioncondition or thenSource or scheduler is null.