Skip to content

})} }})} }},System.Boolean)}

Observable.Defer(Func>) method

Defined in

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

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<TResult> Defer<TResult>(Func<IObservable<TResult>> observableFactory)
  • 2. public static IObservable<TResult> Defer<TResult>(Func<Task<IObservable<TResult>>> observableFactoryAsync)
  • 3. public static IObservable<TResult> Defer<TResult>(Func<Task<IObservable<TResult>>> observableFactoryAsync, bool ignoreExceptionsAfterUnsubscribe)

1. Overload

public static IObservable<TResult> Defer<TResult>(Func<IObservable<TResult>> observableFactory)

Summary: Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.

Type parameters

NameDescription
TResultThe type of the elements in the sequence returned by the factory function, and in the resulting sequence.

Parameters

NameTypeDescription
observableFactoryFunc>Observable factory function to invoke for each observer that subscribes to the resulting sequence.

Returns: IObservable -- An observable sequence whose observers trigger an invocation of the given observable factory function.

Exceptions

TypeCondition
System.ArgumentNullExceptionobservableFactory is null.

2. Overload

public static IObservable<TResult> Defer<TResult>(Func<Task<IObservable<TResult>>> observableFactoryAsync)

Summary: Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.

Type parameters

NameDescription
TResultThe type of the elements in the sequence returned by the factory function, and in the resulting sequence.

Parameters

NameTypeDescription
observableFactoryAsyncFunc>>Asynchronous factory function to start for each observer that subscribes to the resulting sequence.

Returns: IObservable -- An observable sequence whose observers trigger the given asynchronous observable factory function to be started.

Remarks

This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.

Exceptions

TypeCondition
System.ArgumentNullExceptionobservableFactoryAsync is null.

3. Overload

public static IObservable<TResult> Defer<TResult>(Func<Task<IObservable<TResult>>> observableFactoryAsync, bool ignoreExceptionsAfterUnsubscribe)

Summary: Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.

Type parameters

NameDescription
TResultThe type of the elements in the sequence returned by the factory function, and in the resulting sequence.

Parameters

NameTypeDescription
observableFactoryAsyncFunc>>Asynchronous factory function to start for each observer that subscribes to the resulting sequence.
ignoreExceptionsAfterUnsubscribeboolIf true, exceptions that occur after cancellation has been initiated by unsubscribing from the observable this method returns will be handled and silently ignored. If false, they will go unobserved, meaning they will eventually emerge through UnobservedTaskException.

Returns: IObservable -- An observable sequence whose observers trigger the given asynchronous observable factory function to be started.

Remarks

This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.

Exceptions

TypeCondition
System.ArgumentNullExceptionobservableFactoryAsync is null.