using System; namespace UniRx.Operators { internal class AsUnitObservableObservable : OperatorObservableBase { readonly IObservable source; public AsUnitObservableObservable(IObservable source) : base(source.IsRequiredSubscribeOnCurrentThread()) { this.source = source; } protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) { return source.Subscribe(new AsUnitObservable(observer, cancel)); } class AsUnitObservable : OperatorObserverBase { public AsUnitObservable(IObserver observer, IDisposable cancel) : base(observer, cancel) { } public override void OnNext(T value) { base.observer.OnNext(Unit.Default); } public override void OnError(Exception error) { try { observer.OnError(error); } finally { Dispose(); } } public override void OnCompleted() { try { observer.OnCompleted(); } finally { Dispose(); } } } } }