# AsyncBatchObservableExtensions.SubscribeAsync(IAsyncBatchObservable&lt;T&gt;, Func&lt;IList&lt;SequentialItem&lt;T&gt;&gt;, Task&gt;, Func&lt;Exception, Task&gt;, Func&lt;Task&gt;)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.asyncbatchobservableextensions/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.asyncbatchobservableextensions/methods/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/Extensions/AsyncBatchObservableExtensions.cs#L33-L34)

```csharp
public static Task<StreamSubscriptionHandle<T>> SubscribeAsync<T>(this IAsyncBatchObservable<T> obs, Func<IList<SequentialItem<T>>, Task> onNextAsync, Func<Exception, Task> onErrorAsync, Func<Task> onCompletedAsync)
```

Subscribe a consumer to this observable using delegates. This method is a helper for the IAsyncBatchObservable.SubscribeAsync allowing the subscribing class to inline the handler methods instead of requiring an instance of IAsyncBatchObserver.

### Parameters

- `obs` (`IAsyncBatchObservable<T>`): The Observable object.
- `onNextAsync` (`Func<IList<SequentialItem<T>>, Task>`): Delegate that is called for IAsyncBatchObserver.OnNextAsync.
- `onErrorAsync` (`Func<Exception, Task>`): Delegate that is called for IAsyncBatchObserver.OnErrorAsync.
- `onCompletedAsync` (`Func<Task>`): Delegate that is called for IAsyncBatchObserver.OnCompletedAsync.

### Returns

A promise for a StreamSubscriptionHandle that represents the subscription. The consumer may unsubscribe by using this handle. The subscription remains active for as long as it is not explicitly unsubscribed.
