neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.01k stars 895 forks source link

ReadOnlyReactiveProperty does not call OnCompleted in some cases #536

Open ymfact opened 7 months ago

ymfact commented 7 months ago

When OnCompleted is called on a Subject, the associated ReadOnlyReactiveProperty's OnCompleted should also be invoked, but it is not happening as expected.

var subject = new Subject<Unit>();
var readOnlyReactiveProperty = subject.ToReadOnlyReactiveProperty();
readOnlyReactiveProperty.Subscribe(
    onNext: _ => Console.WriteLine("OnNext"),
    onCompleted: () => Console.WriteLine("OnCompleted"));
subject.OnCompleted();

Nothing is printed to the console with this code, whereas 'OnCompleted' should be outputted.