IObservable

Gets the information (baso the list)

IObservable is not implemented in any version of net that you would use.

IObservable is similar to IEnumerator and that it's essentially a list.

Where are IObservable differs from IEnumerator you essentially say get me this value IObservable works by when there's a value that comes in that triggers your code like an event.

To use this interface you will need to use an external package since it is not implemented in any version of .net

In the following example we can use it in the Reactive.Linq package.

Minimal Example

using System.Reactive.Linq;

namespace RxDemo;

class Program
{
    static void Main(string[] args)
    {
        IObservable<int> observable = Observable.Range(1, 10);

        observable.Subscribe(val => Console.WriteLine(val));
    }
}

// outputs: 1 through 10

General Flow

  1. IObservable.Subscribe
  1. That gives you an IDisposable
    1. The IDisposable essentially allows you to break of of the subscription

Implementations of Observable