Skip to content

[BUG] InvokeCommand doesn't invoke command #2866

@Micha-kun

Description

@Micha-kun

I upgraded to latest version (from 14.1.1 to 14.2.1) and, suddenly, InvokeCommand from an observable stopped to invoke my command. Command espects an Unit (in this context) as input, but command invocation is ignored. If I force to invoke manually that command, it executes correctly, but not via binding. Command doesn't have any validation for CanExecute or nothing.

Steps To Reproduce
1 - Command creation:

this.InitializeCommand = ReactiveCommand.CreateFromObservable<TInput, Unit>(
                inputCmd =>
                {
                    // Never enters via InvokeCommand, but enters when Execute call method is used.
                    return Observable.FromAsync(
                                          async ct =>
                                          {
                                              .....
                                          })
                                     .TakeUntil(this.CancelInitializeCommand);

                });

2 - Binding initialization:

this.WhenAnyValue(vm => vm.Input)
      // .Do(_ => Debug.WriteLine("Arrives?") --> YES, it arrives
      .WhereNotNull()
      // .Do(_ => Debug.WriteLine("Arrives?") --> YES, it arrives
      .DistinctUntilChanged()
      // .Do(_ => Debug.WriteLine("Arrives?") --> YES, it arrives
      .InvokeCommand(this.InitializeCommand) // Does nothing
      .DisposeWith(d);

Expected behavior
Command is called on InvokeCommand.

Environment

  • OS: Windows 10
  • Version 21H1
  • Device: PC
  • Application Type: WinForms Application
  • SDK: .NET Framework 4.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions