Skip to content

}})} })}

ObservableAsync.Defer(Func>>) method

Defined in

Type: ObservableAsync Namespace: ReactiveUI.Extensions.Async Assembly: ReactiveUI.Extensions.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

Overloads

  • 1. public static IObservableAsync<T> Defer<T>(Func<CancellationToken, ValueTask<IObservableAsync<T>>> factory)
  • 2. public static IObservableAsync<T> Defer<T>(Func<IObservableAsync<T>> factory)

1. Overload

public static IObservableAsync<T> Defer<T>(Func<CancellationToken, ValueTask<IObservableAsync<T>>> factory)

View source

Summary: Creates a new observable sequence for each subscription by invoking the specified asynchronous factory function.

Type parameters

NameDescription
TThe type of the elements produced by the observable sequence.

Parameters

NameTypeDescription
factoryFunc>>A function that receives a cancellation token and returns a task that produces an observable sequence to subscribe to.

Returns: IObservableAsync -- An observable sequence that, upon each subscription, invokes the factory function to obtain the actual observable sequence to subscribe to.

Remarks

Use this method to defer the creation of the observable sequence until an observer subscribes. This is useful when the observable sequence depends on per-subscription state or resources, or when you want to ensure a fresh sequence for each subscriber.

2. Overload

public static IObservableAsync<T> Defer<T>(Func<IObservableAsync<T>> factory)

View source

Summary: Returns an observable sequence that is created by invoking the specified factory function each time a new observer subscribes.

Type parameters

NameDescription
TThe type of the elements produced by the observable sequence.

Parameters

NameTypeDescription
factoryFunc>A function that returns a new instance of an observable sequence to be subscribed to for each observer.

Returns: IObservableAsync -- An observable sequence whose observers trigger the invocation of the factory function upon subscription.

Remarks

Use this method to defer the creation of the observable sequence until an observer subscribes, ensuring that each subscription receives a fresh instance. This is useful when the observable sequence has side effects or depends on external state at the time of subscription.