Tyoshi
Tyoshi

Reputation: 9

What is the relationship between IObservable and ObservableExtensions in Rx?

I read the code of Reactive Extension, then I find this code

private readonly IObservable<TSource> _source;
protected override IDisposable Run(IObserver<TResult> observer, IDisposable cancel, Action<IDisposable> setSink)
{
    var sink = new _(this, observer, cancel);
    setSink(sink);
    return _source.SubscribeSafe(sink);
}

I find that the method SubscribeSafe(sink) is in the class ObservableExtensions, and the class isn't implement the interface IObservable. Why the parameter _source have the member function SubscribeSafe()?

Upvotes: 0

Views: 320

Answers (1)

Moti Azu
Moti Azu

Reputation: 5442

It's because the methods in ObservableExtensions are extension methods. You can read about them here.

Upvotes: 2

Related Questions