,System.Func{System.Threading.Channels.Channel{--0}})} ,System.Func{System.Threading.Channels.Channel{--0}},System.Func{System.Exception,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask})}
ObservableAsync.ToAsyncEnumerable(IObservableAsync, 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 IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IObservableAsync<T> @this, Func<Channel<T>> channelFactory) - 2.
public static IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IObservableAsync<T> @this, Func<Channel<T>> channelFactory, Func<Exception, CancellationToken, ValueTask>? onErrorResume)
1. Overload¶
public static IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IObservableAsync<T> @this, Func<Channel<T>> channelFactory)
Summary: Converts the specified asynchronous observable sequence to an asynchronous enumerable sequence, enabling consumption using asynchronous iteration.
Type parameters
| Name | Description |
|---|---|
T | The type of elements contained within the asynchronous observable and the resulting asynchronous enumerable. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The asynchronous observable to convert into an asynchronous enumerable. |
channelFactory | Func | A factory function that produces a channel to buffer elements, controlling the buffering and backpressure behavior between the asynchronous observable and the asynchronous enumerable. |
Returns: IAsyncEnumerable
Remarks
The resulting asynchronous enumerable sequence reflects the items and completion behavior of the source
asynchronous observable. The buffering behavior is determined by the channel created by the provided
channelFactory.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when this or channelFactory is null. |
2. Overload¶
public static IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IObservableAsync<T> @this, Func<Channel<T>> channelFactory, Func<Exception, CancellationToken, ValueTask>? onErrorResume)
Summary: Converts the specified observable sequence to an asynchronous enumerable sequence, enabling consumption using asynchronous iteration.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the observable and resulting asynchronous enumerable sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The observable sequence to convert to an asynchronous enumerable. |
channelFactory | Func | A factory function that creates a new channel used to buffer items between the observable and the asynchronous enumerable. The channel controls the buffering and backpressure behavior. |
onErrorResume | Func | An optional asynchronous callback invoked when an error occurs in the observable sequence. If provided, this function can handle the exception and determine how the sequence should resume or complete. If null, the sequence completes with the error. |
Returns: IAsyncEnumerable
Remarks
The returned asynchronous enumerable reflects the items and completion behavior of the source
observable. The buffering and concurrency characteristics depend on the channel created by channelFactory. If onErrorResume is provided, it can be used to suppress or handle
errors from the observable; otherwise, errors are propagated to the enumerator.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if this or channelFactory is null. |