# AsyncBatchObservableExtensions Methods

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

## SubscribeAsync(IAsyncBatchObservable&lt;T&gt;, Func&lt;IList&lt;SequentialItem&lt;T&gt;&gt;, Task&gt;) {#subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-01b55956}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.asyncbatchobservableextensions/methods/subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-01b55956/)

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

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

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.

### 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.

## SubscribeAsync(IAsyncBatchObservable&lt;T&gt;, Func&lt;IList&lt;SequentialItem&lt;T&gt;&gt;, Task&gt;, Func&lt;Exception, Task&gt;) {#subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-57e4421f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.asyncbatchobservableextensions/methods/subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-57e4421f/)

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

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

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.

### 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.

## 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;) {#subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-5927d51e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.asyncbatchobservableextensions/methods/subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-5927d51e/)

[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.

## SubscribeAsync(IAsyncBatchObservable&lt;T&gt;, Func&lt;IList&lt;SequentialItem&lt;T&gt;&gt;, Task&gt;, Func&lt;Task&gt;) {#subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-f4d1e53d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.streams.asyncbatchobservableextensions/methods/subscribeasync-1-this-orleans-streams-iasyncbatchobservable-t-system-func-system-f4d1e53d/)

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

```csharp
public static Task<StreamSubscriptionHandle<T>> SubscribeAsync<T>(this IAsyncBatchObservable<T> obs, Func<IList<SequentialItem<T>>, Task> onNextAsync, 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.
- `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.
