)} ,System.Action{--0})} ,System.Action{--0},System.Action{System.Exception})} ,System.Action{--0},System.Action)} ,System.Action{--0},System.Action{System.Exception},System.Action)} ,System.IObserver{--0},System.Threading.CancellationToken)} ,System.Threading.CancellationToken)} ,System.Action{--0},System.Threading.CancellationToken)} ,System.Action{--0},System.Action{System.Exception},System.Threading.CancellationToken)} ,System.Action{--0},System.Action,System.Threading.CancellationToken)} ,System.Action{--0},System.Action{System.Exception},System.Action,System.Threading.CancellationToken)}
ObservableExtensions.Subscribe(IObservable) method¶
Defined in
Type: ObservableExtensions
Namespace: System
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IDisposable Subscribe<T>(this IObservable<T> source) - 2.
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext) - 3.
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError) - 4.
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted) - 5.
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted) - 6.
public static void Subscribe<T>(this IObservable<T> source, IObserver<T> observer, CancellationToken token) - 7.
public static void Subscribe<T>(this IObservable<T> source, CancellationToken token) - 8.
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, CancellationToken token) - 9.
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, CancellationToken token) - 10.
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted, CancellationToken token) - 11.
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted, CancellationToken token)
1. Overload¶
public static IDisposable Subscribe<T>(this IObservable<T> source)
Summary: Subscribes to the observable sequence without specifying any handlers. This method can be used to evaluate the observable sequence for its side-effects only.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
Returns: IDisposable -- IDisposable object used to unsubscribe from the observable sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
2. Overload¶
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext)
Summary: Subscribes an element handler to an observable sequence.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
Returns: IDisposable -- IDisposable object used to unsubscribe from the observable sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext is null. |
3. Overload¶
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError)
Summary: Subscribes an element handler and an exception handler to an observable sequence.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
onError | Action | Action to invoke upon exceptional termination of the observable sequence. |
Returns: IDisposable -- IDisposable object used to unsubscribe from the observable sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext or onError is null. |
4. Overload¶
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted)
Summary: Subscribes an element handler and a completion handler to an observable sequence.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
onCompleted | Action | Action to invoke upon graceful termination of the observable sequence. |
Returns: IDisposable -- IDisposable object used to unsubscribe from the observable sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext or onCompleted is null. |
5. Overload¶
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted)
Summary: Subscribes an element handler, an exception handler, and a completion handler to an observable sequence.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
onError | Action | Action to invoke upon exceptional termination of the observable sequence. |
onCompleted | Action | Action to invoke upon graceful termination of the observable sequence. |
Returns: IDisposable -- IDisposable object used to unsubscribe from the observable sequence.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext or onError or onCompleted is null. |
6. Overload¶
public static void Subscribe<T>(this IObservable<T> source, IObserver<T> observer, CancellationToken token)
Summary: Subscribes an observer to an observable sequence, using a CancellationToken to support unsubscription.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
observer | IObserver | Observer to subscribe to the sequence. |
token | CancellationToken | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or observer is null. |
7. Overload¶
public static void Subscribe<T>(this IObservable<T> source, CancellationToken token)
Summary: 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.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
token | CancellationToken | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
8. Overload¶
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, CancellationToken token)
Summary: Subscribes an element handler to an observable sequence, using a CancellationToken to support unsubscription.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
token | CancellationToken | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext is null. |
9. Overload¶
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, CancellationToken token)
Summary: Subscribes an element handler and an exception handler to an observable sequence, using a CancellationToken to support unsubscription.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
onError | Action | Action to invoke upon exceptional termination of the observable sequence. |
token | CancellationToken | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext or onError is null. |
10. Overload¶
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action onCompleted, CancellationToken token)
Summary: Subscribes an element handler and a completion handler to an observable sequence, using a CancellationToken to support unsubscription.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
onCompleted | Action | Action to invoke upon graceful termination of the observable sequence. |
token | CancellationToken | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext or onCompleted is null. |
11. Overload¶
public static void Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError, Action onCompleted, CancellationToken token)
Summary: Subscribes an element handler, an exception handler, and a completion handler to an observable sequence, using a CancellationToken to support unsubscription.
Type parameters
| Name | Description |
|---|---|
T | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Observable sequence to subscribe to. |
onNext | Action | Action to invoke for each element in the observable sequence. |
onError | Action | Action to invoke upon exceptional termination of the observable sequence. |
onCompleted | Action | Action to invoke upon graceful termination of the observable sequence. |
token | CancellationToken | CancellationToken that can be signaled to unsubscribe from the source sequence. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or onNext or onError or onCompleted is null. |