0

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()?

Moti Azu
  • 5,392
  • 1
  • 23
  • 32
Tyoshi
  • 9
  • 2

1 Answers1

2

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

Moti Azu
  • 5,392
  • 1
  • 23
  • 32