ObservableAsync.ToObservableAsync(Task) 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> ToObservableAsync<T>(this Task<T> @this) - 2.
public static IObservableAsync<Unit> ToObservableAsync(this Task @this) - 3.
public static IObservableAsync<T> ToObservableAsync<T>(this IAsyncEnumerable<T> @this) - 4.
public static IObservableAsync<T> ToObservableAsync<T>(this IEnumerable<T> @this)
1. Overload¶
public static IObservableAsync<T> ToObservableAsync<T>(this Task<T> @this)
Summary: Converts a task representing a single asynchronous value into an observable sequence that emits the result when the task completes.
Type parameters
| Name | Description |
|---|---|
T | The type of the value produced by the task and emitted by the observable sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
this | Task | The task to convert to an asynchronous observable sequence. Cannot be null. |
Returns: IObservableAsync
Remarks
The returned observable will emit the task's result and then complete. If the task is canceled or fails, the observable will propagate the corresponding error. The task is awaited in the background, and cancellation is supported via the observable's subscription.
2. Overload¶
public static IObservableAsync<Unit> ToObservableAsync(this Task @this)
Summary: Converts the specified task into an asynchronous observable sequence that signals completion when the task finishes.
Parameters
| Name | Type | Description |
|---|---|---|
this | Task | The task to be observed. Cannot be null. |
Returns: IObservableAsync
Remarks
The returned observable emits a single unit value upon task completion and then signals completion. If the task is canceled or fails, the observable will propagate the corresponding error. This method is useful for integrating task-based operations into observable workflows.
3. Overload¶
public static IObservableAsync<T> ToObservableAsync<T>(this IAsyncEnumerable<T> @this)
Summary: Converts an asynchronous enumerable sequence to an asynchronous observable sequence.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
this | IAsyncEnumerable | The asynchronous enumerable sequence to convert. Cannot be null. |
Returns: IObservableAsync
Remarks
The returned observable emits each element from the source sequence as it is produced and signals completion when the source sequence ends. Cancellation is supported via the observer's cancellation token.
4. Overload¶
public static IObservableAsync<T> ToObservableAsync<T>(this IEnumerable<T> @this)
Summary: Converts the specified enumerable sequence to an asynchronous observable sequence, emitting each element in the background.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
this | IEnumerable | The enumerable sequence to convert to an asynchronous observable. Cannot be null. |
Returns: IObservableAsync
Remarks
The returned observable emits items on a background thread. Cancellation is supported via the observer's cancellation token. If the source sequence is empty, the observable completes immediately.