-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug 🐞
I'm developing a .NET 10 WinForms app using ReactiveUI 23.1.8 and ReactiveUI.SourceGenerators 2.6.1. I'm trying to use the output of a ReactiveCommand so I can invoke another commands or binding to property, but I'm getting no response in any way.
Step to reproduce
I have this viewmodel. There are comments where problems arise.
public ShellViewModel(ISchedulerProvider schedulerProvider)
{
this.Router = new(schedulerProvider.MainThread);
this.schedulerProvider = schedulerProvider;
this.WhenActivated(
d =>
{
_ = this.WhenAnyObservable(vm => vm.NavigateToCommand).Subscribe(x => { }).DisposeWith(d); // Does nothing
_ = this.NavigateToCommand.IsExecuting.Subscribe(_ => { }).DisposeWith(d); // Only generates the first false value
_ = this.NavigateToCommand.Subscribe(x => { }).DisposeWith(d); // Does nothing
_ = Observable.Return(ShellPages.Clients).InvokeCommand(this, vm => vm.NavigateToCommand).DisposeWith(d); // This executes as expected
// _ = this.NavigateToCommand.Execute(ShellPages.Clients).Subscribe().DisposeWith(d); // I tried that too, executes as expected, propagates nothing.
});
}
[ReactiveCommand]
private IObservable<IRoutableViewModel?> NavigateTo(ShellPages shellPage)
{
return Observable.Create<IRoutableViewModel?>(observer =>
{
var result = ... // Get new routable viewmodel
observer.OnNext(result);
Thread.Sleep(TimeSpan.FromSeconds(5)); // This is forced for testing, to see if IsExecuting would rise. It doesn't change anything if it exists or not.
observer.OnCompleted();
return Disposable.Empty;
}).WhereNotNull().SelectMany(this.Router.NavigateAndReset.Execute);
}Command executes completelly, even the NavigateAndReset command one, and Router.CurrentViewModel observable responds as expected.
Firstly I tried to make that navigation thing as response from the output of the command, but because didn't work, I put inside command, but I don't like that, I prefer to use ReactiveCommand as an output propagator.
Reproduction repository
https://github.com/reactiveui/ReactiveUI
Expected behavior
ReactiveCommand output should be propagated.
Screenshots 🖼️
No response
IDE
Visual Studio 2026
Operating system
Windows 11
Version
No response
Device
No response
ReactiveUI Version
23.1.8
Additional information ℹ️
No response