Class ObserverBase<T>
Abstract base class for implementations of the IObserver<T> interface.
Inherited Members
Namespace: System.Reactive
Assembly: System.Reactive.Core.dll
Syntax
public abstract class ObserverBase<T> : IObserver<T>, IDisposable
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence. |
Remarks
This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
Constructors
| Improve this Doc View SourceObserverBase()
Creates a new observer in a non-stopped state.
Declaration
protected ObserverBase()
Methods
| Improve this Doc View SourceDispose()
Disposes the observer, causing it to transition to the stopped state.
Declaration
public void Dispose()
Dispose(Boolean)
Core implementation of IDisposable.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | true if the Dispose call was triggered by the IDisposable.Dispose method; false if it was triggered by the finalizer. |
OnCompleted()
Notifies the observer of the end of the sequence.
Declaration
public void OnCompleted()
OnCompletedCore()
Implement this method to react to the end of the sequence.
Declaration
protected abstract void OnCompletedCore()
Remarks
This method only gets called when the observer hasn't stopped yet, and causes the observer to stop.
OnError(Exception)
Notifies the observer that an exception has occurred.
Declaration
public void OnError(Exception error)
Parameters
Type | Name | Description |
---|---|---|
Exception | error | The error that has occurred. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OnErrorCore(Exception)
Implement this method to react to the occurrence of an exception.
Declaration
protected abstract void OnErrorCore(Exception error)
Parameters
Type | Name | Description |
---|---|---|
Exception | error | The error that has occurred. |
Remarks
This method only gets called when the observer hasn't stopped yet, and causes the observer to stop.
OnNext(T)
Notifies the observer of a new element in the sequence.
Declaration
public void OnNext(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Next element in the sequence. |
OnNextCore(T)
Implement this method to react to the receival of a new element in the sequence.
Declaration
protected abstract void OnNextCore(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Next element in the sequence. |
Remarks
This method only gets called when the observer hasn't stopped yet.