diff --git a/src/R3/Observable.cs b/src/R3/Observable.cs index 40bc9557..cab4a1f5 100644 --- a/src/R3/Observable.cs +++ b/src/R3/Observable.cs @@ -4,7 +4,7 @@ namespace R3; -public abstract class Observable : IObservable +public abstract class Observable { [StackTraceHidden, DebuggerStepThrough] public IDisposable Subscribe(Observer observer) @@ -29,14 +29,9 @@ public IDisposable Subscribe(Observer observer) } protected abstract IDisposable SubscribeCore(Observer observer); - - IDisposable IObservable.Subscribe(IObserver observer) - { - return Subscribe(observer.ToObserver()); // convert IObserver to Observer - } } -public abstract class Observer : IDisposable, IObserver +public abstract class Observer : IDisposable { #if DEBUG [Obsolete("Only allow in Event.")] @@ -122,21 +117,4 @@ public void Dispose() [StackTraceHidden, DebuggerStepThrough] protected virtual void DisposeCore() { } - - // IObserver bridge - - void IObserver.OnNext(T value) - { - OnNext(value); - } - - void IObserver.OnError(Exception error) - { - OnCompleted(Result.Failure(error)); - } - - void IObserver.OnCompleted() - { - OnCompleted(Result.Success); - } } diff --git a/src/R3/Operators/ToIObservable.cs b/src/R3/Operators/AsObservable.cs similarity index 68% rename from src/R3/Operators/ToIObservable.cs rename to src/R3/Operators/AsObservable.cs index 99e796a8..70874939 100644 --- a/src/R3/Operators/ToIObservable.cs +++ b/src/R3/Operators/AsObservable.cs @@ -3,20 +3,20 @@ public static partial class ObservableExtensions { // TODO: more overload? - public static IObservable ToIObservable(this Observable source) + public static IObservable AsObservable(this Observable source) { - return new ToIObservable(source); + return new AsObservable(source); } } -internal sealed class ToIObservable(Observable source) : IObservable +internal sealed class AsObservable(Observable source) : IObservable { public IDisposable Subscribe(IObserver observer) { - return source.Subscribe(new ObserverToobserver(observer)); + return source.Subscribe(new ObserverToObserver(observer)); } - sealed class ObserverToobserver(IObserver observer) : Observer + sealed class ObserverToObserver(IObserver observer) : Observer { protected override void OnNextCore(T value) {