// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
namespace System.Reactive.Subjects
{
///
/// Base class for objects that are both an observable sequence as well as an observer.
///
/// The type of the elements processed by the subject.
#pragma warning disable CA1063 // (Overridable IDisposable.) This analyzer wants us to make breaking changes to its public API, which we can't do.
public abstract class SubjectBase : ISubject, IDisposable
{
///
/// Indicates whether the subject has observers subscribed to it.
///
public abstract bool HasObservers { get; }
///
/// Indicates whether the subject has been disposed.
///
public abstract bool IsDisposed { get; }
///
/// Releases all resources used by the current instance of the subject and unsubscribes all observers.
///
public abstract void Dispose();
///
/// Notifies all subscribed observers about the end of the sequence.
///
public abstract void OnCompleted();
///
/// Notifies all subscribed observers about the specified exception.
///
/// The exception to send to all currently subscribed observers.
/// is null.
#pragma warning disable CA1716 // (Identifiers should not match keywords.) This has been the name for years, so the (admittedly small) risk from changing it doesn't seem to offer a meaningful benefit.
public abstract void OnError(Exception error);
#pragma warning restore CA1716
///
/// Notifies all subscribed observers about the arrival of the specified element in the sequence.
///
/// The value to send to all currently subscribed observers.
public abstract void OnNext(T value);
///
/// Subscribes an observer to the subject.
///
/// Observer to subscribe to the subject.
/// Disposable object that can be used to unsubscribe the observer from the subject.
/// is null.
public abstract IDisposable Subscribe(IObserver observer);
}
#pragma warning restore CA1063
}