Class Subscriber<T>
- Namespace
- RxSharp
- Assembly
- RxSharp.dll
Wraps an IObserver<T> with unsubscribe-aware, re-entrancy-guarded dispatch. Mirrors rxjs's Subscriber.
Deliberately does not swallow exceptions thrown by the wrapped observer's callbacks: it is each operator's own
responsibility to catch exceptions from user-supplied callbacks (projections, predicates, side effects) and
forward them via OnError(Exception) — see RxSharp/Operators for the pattern. A generic catch-and-forward
here would double up across nested operator chains and silently swallow errors instead of propagating them.
public class Subscriber<T> : Subscription, IObserver<T>
Type Parameters
TThe type of the values this subscriber accepts.
- Inheritance
-
System.ObjectSubscriber<T>
- Implements
-
IObserver<T>
- Inherited Members
Constructors
Subscriber(IObserver<T>)
Initializes a new instance of the Subscriber<T> class wrapping the given observer.
public Subscriber(IObserver<T> observer)
Parameters
observerIObserver<T>The observer notifications are forwarded to.
Methods
OnCompleted()
Notifies the wrapped observer of completion, then unsubscribes. A no-op if this subscriber has already stopped or been disposed. After this call, further OnNext(T)/OnError(Exception)/OnCompleted() calls are ignored.
public void OnCompleted()
OnError(Exception)
Forwards error to the wrapped observer, then unsubscribes. A no-op if this subscriber
has already stopped or been disposed. After this call, further OnNext(T)/OnError(Exception)/OnCompleted()
calls are ignored.
public void OnError(Exception error)
Parameters
errorExceptionThe error to forward.
OnNext(T)
Forwards value to the wrapped observer, unless this subscriber has already stopped (via error/completion) or been disposed, in which case the call is silently ignored.
public void OnNext(T value)
Parameters
valueTThe value to push.