Skip to content

})} )}

ObservableAsync.FromAsync(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> FromAsync<T>(Func<CancellationToken, ValueTask<T>> factory)
  • 2. public static IObservableAsync<Unit> FromAsync(Func<CancellationToken, ValueTask> factory)

1. Overload

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

View source

Summary: Creates an asynchronous observable sequence that emits a single value produced by the specified factory function.

Type parameters

NameDescription
TThe type of the value produced by the factory and emitted by the observable sequence.

Parameters

NameTypeDescription
factoryFunc>A function that asynchronously produces a value of type T when invoked with a CancellationToken. Cannot be null.

Returns: IObservableAsync -- An ObservableAsync that emits the value returned by the factory function and then completes.

Remarks

The observable sequence will emit the value produced by the factory and then signal completion. The factory function is invoked when the sequence is subscribed to, and supports cancellation via the provided CancellationToken.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if factory is null.

2. Overload

public static IObservableAsync<Unit> FromAsync(Func<CancellationToken, ValueTask> factory)

View source

Summary: Creates an asynchronous observable sequence that executes the specified factory function and signals completion when the operation finishes.

Parameters

NameTypeDescription
factoryFuncA function that performs the asynchronous operation. The function receives a cancellation token that can be used to cancel the operation.

Returns: IObservableAsync -- An observable sequence that emits a single value of Unit when the factory function completes, followed by a completion notification.

Remarks

The returned observable executes the factory function as a background job. The sequence emits Default after the factory completes and then signals completion. Cancellation is supported via the provided token.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if factory is null.