IObservable<T> Interface

July 28, 2014

Defines a provider for push-based notification.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public interface IObservable<out T>

Type Parameters

out T

The object that provides notification information.

This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see [2678dc63-c7f9-4590-9ddc-0a4df684d42e].

The IObservable<T> type exposes the following members.

  NameDescription
Public methodSubscribeSubscribes observer to receive notifications.
Top

Provides an observable object mechanism to support push-style iteration over an observable sequence for publish/subscribe event processing.

The IObserver<T> and IObservable<T> interfaces provide a generalized mechanism for push-based notification, also known as the observer design pattern. The IObservable<T> interface represents the class that sends notifications (the provider); the IObserver<T> interface represents the class that receives them (the observer). T represents the class that provides the notification information.

An IObserver<T> implementation arranges to receive notifications from a provider (an IObservable<T> implementation) by passing an instance of itself to the provider's IObservable<T>.Subscribe method. This method returns an IDisposable object that can be used to unsubscribe the observer before the provider finishes sending notifications.

The IObserver<T> interface defines the following three methods that the observer must implement:

  • The OnNext method, which is typically called by the provider to supply the observer with new data or state information.

  • The OnError method, which is typically called by the provider to indicate that data is unavailable, inaccessible, or corrupted, or that the provider has experienced some other error condition.

  • The OnCompleted method, which is typically called by the provider to indicate that it has finished sending notifications to observers.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft