Class ObservableExtensions
Provides a set of static methods for subscribing delegates to observables.
Inherited Members
Namespace: System
Assembly: System.Reactive.Core.dll
Syntax
public static class ObservableExtensions
Methods
| Improve this Doc View SourceSubscribe<T>(IObservable<T>)
Subscribes to the observable sequence without specifying any handlers. This method can be used to evaluate the observable sequence for its side-effects only.
Declaration
public static IDisposable Subscribe<T>(this IObservable<T> source)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Returns
Type | Description |
---|---|
IDisposable | IDisposable object used to unsubscribe from the observable sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>)
Subscribes an element handler to an observable sequence.
Declaration
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Returns
Type | Description |
---|---|
IDisposable | IDisposable object used to unsubscribe from the observable sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, Action)
Subscribes an element handler and a completion handler to an observable sequence.
Declaration
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Action | onCompleted | Action to invoke upon graceful termination of the observable sequence. |
Returns
Type | Description |
---|---|
IDisposable | IDisposable object used to unsubscribe from the observable sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, Action, CancellationToken)
Subscribes an element handler and a completion handler to an observable sequence, using a CancellationToken to support unsubscription.
Declaration
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Action | onCompleted | Action to invoke upon graceful termination of the observable sequence. |
CancellationToken | token | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, Action<Exception>)
Subscribes an element handler and an exception handler to an observable sequence.
Declaration
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Action<Exception> | onError | Action to invoke upon exceptional termination of the observable sequence. |
Returns
Type | Description |
---|---|
IDisposable | IDisposable object used to unsubscribe from the observable sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, Action<Exception>, Action)
Subscribes an element handler, an exception handler, and a completion handler to an observable sequence.
Declaration
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Action<Exception> | onError | Action to invoke upon exceptional termination of the observable sequence. |
Action | onCompleted | Action to invoke upon graceful termination of the observable sequence. |
Returns
Type | Description |
---|---|
IDisposable | IDisposable object used to unsubscribe from the observable sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, Action<Exception>, Action, CancellationToken)
Subscribes an element handler, an exception handler, and a completion handler to an observable sequence, using a CancellationToken to support unsubscription.
Declaration
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Action<Exception> | onError | Action to invoke upon exceptional termination of the observable sequence. |
Action | onCompleted | Action to invoke upon graceful termination of the observable sequence. |
CancellationToken | token | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, Action<Exception>, CancellationToken)
Subscribes an element handler and an exception handler to an observable sequence, using a CancellationToken to support unsubscription.
Declaration
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
Action<Exception> | onError | Action to invoke upon exceptional termination of the observable sequence. |
CancellationToken | token | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, Action<T>, CancellationToken)
Subscribes an element handler to an observable sequence, using a CancellationToken to support unsubscription.
Declaration
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
Action<T> | onNext | Action to invoke for each element in the observable sequence. |
CancellationToken | token | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, IObserver<T>, CancellationToken)
Subscribes an observer to an observable sequence, using a CancellationToken to support unsubscription.
Declaration
public static void Subscribe<T>(this IObservable<T> source, IObserver<T> observer, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
IObserver<T> | observer | Observer to subscribe to the sequence. |
CancellationToken | token | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Subscribe<T>(IObservable<T>, CancellationToken)
Subscribes to the observable sequence without specifying any handlers, using a CancellationToken to support unsubscription. This method can be used to evaluate the observable sequence for its side-effects only.
Declaration
public static void Subscribe<T>(this IObservable<T> source, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
CancellationToken | token | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SubscribeSafe<T>(IObservable<T>, IObserver<T>)
Subscribes to the specified source, re-routing synchronous exceptions during invocation of the Subscribe method to the observer's OnError channel. This method is typically used when writing query operators.
Declaration
public static IDisposable SubscribeSafe<T>(this IObservable<T> source, IObserver<T> observer)
Parameters
Type | Name | Description |
---|---|---|
IObservable<T> | source | Observable sequence to subscribe to. |
IObserver<T> | observer | Observer that will be passed to the observable sequence, and that will be used for exception propagation. |
Returns
Type | Description |
---|---|
IDisposable | IDisposable object used to unsubscribe from the observable sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the source sequence. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|