#536·UniRx

ReadOnlyReactiveProperty does not call OnCompleted in some cases

Author: ymfactCreated Nov 28, 2023Updated Nov 29, 2023

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

csharp
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.