Skip to content

Conversation

TORISOUP
Copy link
Contributor

@TORISOUP TORISOUP commented May 1, 2025

As pointed out in #330, when using AsObservable() in combination with message-delaying operators such as Delay or ObserveOn, the OnCompleted signal was not properly propagated downstream.

var subject = new Subject<Unit>();
var fakeFrameProvider = new FakeFrameProvider();

subject
    .AsObservable()
    .ObserveOn(fakeFrameProvider)
    .Subscribe(
        onNext: _ => Console.WriteLine("Next"),
        onCompleted: _ => Console.WriteLine("Completed")
    );

subject.OnNext(Unit.Default);
fakeFrameProvider.Advance();
subject.OnCompleted();
fakeFrameProvider.Advance();

// "Completed" is not printed

The cause was that WrappedObserver is defined with AutoDisposeOnCompleted = true, and AsObservable() uses it as-is.
As a fix, AsObservable() now uses a dedicated observer.

A similar issue was also present in AsSystemObservable(), so it has been fixed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant