Skip to content

,System.Windows.Input.ICommand)} ,System.IObservable)}

CommandInvoker.Invoke(IObservable, ICommand) method

Defined in

Type: CommandInvoker Namespace: ReactiveUI.Binding.Reactive.CommandBinding Assembly: ReactiveUI.Binding.Reactive.dll

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-tvos18.0, net9.0-maccatalyst18.0, net9.0-ios18.0, net9.0-macos15.0, net9.0-desktop1.0, net8.0, net8.0-macos14.5, net8.0-ios18.0, net8.0-maccatalyst18.0, net8.0-macos15.0, net8.0-tvos18.0, net8.0-ios17.5, net8.0-maccatalyst17.5, netstandard2.1, net481, net462, net471

Overloads

  • 1. public static IDisposable Invoke<T>(IObservable<T> source, ICommand command)
  • 2. public static IDisposable Invoke<T>(IObservable<T> source, IObservable<ICommand?> commands)

1. Overload

public static IDisposable Invoke<T>(IObservable<T> source, ICommand command)

View source

Summary: Executes one command with each value the sequence produces.

Type parameters

NameDescription
TThe type of the value offered as the command parameter.

Parameters

NameTypeDescription
sourceIObservableThe sequence driving the executions.
commandICommandThe command to execute.

Returns: IDisposable -- A disposable that, when disposed, stops executing the command.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or command is null.

2. Overload

public static IDisposable Invoke<T>(IObservable<T> source, IObservable<ICommand?> commands)

View source

Summary: Executes whichever command the observed sequence of commands last produced.

Type parameters

NameDescription
TThe type of the value offered as the command parameter.

Parameters

NameTypeDescription
sourceIObservableThe sequence driving the executions.
commandsIObservableThe command to execute, as the observed property produces it.

Returns: IDisposable -- A disposable that, when disposed, stops executing and stops observing the property.

Remarks

The commands are subscribed first, so the command the property already holds is latched before any value can arrive. Subscribing in the other order drops a value produced immediately.

A null command - a property not yet assigned, or a path through an absent parent - drops the values offered while it stands, and a later command picks up from the next value. Replacing the command executes nothing by itself: values are what drive an execution, which is why the two sequences are not combined.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or commands is null.