Table of Contents

Class CombinedReactiveCommand<TParam, TResult>

Namespace
ReactiveUI
Assembly
ReactiveUI.dll

Encapsulates a composite user interaction.

public class CombinedReactiveCommand<TParam, TResult> : ReactiveCommandBase<TParam, IList<TResult>>, IReactiveCommand<TParam, IList<TResult>>, IObservable<IList<TResult>>, IReactiveCommand, IDisposable, IHandleObservableErrors, ICommand

Type Parameters

TParam

The type of parameter values passed in during command execution.

TResult

The type of the values that are the result of command execution.

Inheritance
ReactiveCommandBase<TParam, IList<TResult>>
CombinedReactiveCommand<TParam, TResult>
Implements
IReactiveCommand<TParam, IList<TResult>>
IObservable<IList<TResult>>
Inherited Members
Extension Methods
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)

Remarks

This class provides the bulk of the actual implementation for combined reactive commands. You should not create instances of this class directly, but rather via the static creation methods on the non-generic ReactiveCommand class.

A CombinedReactiveCommand combines multiple reactive commands into a single command. Executing the combined command executes all child commands. Since all child commands will receive the same execution parameter, all child commands must accept a parameter of the same type.

In order for the combined command to be executable, all child commands must themselves be executable. In addition, any canExecute observable passed in during construction must also yield true.

Constructors

CombinedReactiveCommand(IEnumerable<ReactiveCommandBase<TParam, TResult>>, IObservable<bool>?, IScheduler?)

Initializes a new instance of the CombinedReactiveCommand<TParam, TResult> class.

protected CombinedReactiveCommand(IEnumerable<ReactiveCommandBase<TParam, TResult>> childCommands, IObservable<bool>? canExecute, IScheduler? outputScheduler = null)

Parameters

childCommands IEnumerable<ReactiveCommandBase<TParam, TResult>>

The child commands which will be executed.

canExecute IObservable<bool>

A observable when the command can be executed.

outputScheduler IScheduler

The scheduler where to dispatch the output from the command.

Exceptions

ArgumentNullException

Fires when required arguments are null.

ArgumentException

Fires if the child commands container is empty.

Properties

CanExecute

Gets an observable whose value indicates whether the command can currently execute.

public override IObservable<bool> CanExecute { get; }

Property Value

IObservable<bool>

The can execute.

Remarks

The value provided by this observable is governed both by any canExecute observable provided during command creation, as well as the current execution status of the command. A command that is currently executing will always yield false from this observable, even if the canExecute pipeline is currently true.

IsExecuting

Gets an observable whose value indicates whether the command is currently executing.

public override IObservable<bool> IsExecuting { get; }

Property Value

IObservable<bool>

The is executing.

Remarks

This observable can be particularly useful for updating UI, such as showing an activity indicator whilst a command is executing.

ThrownExceptions

Gets a observable which will fire whenever an exception would normally terminate ReactiveUI internal state.

public override IObservable<Exception> ThrownExceptions { get; }

Property Value

IObservable<Exception>

Methods

Dispose(bool)

Disposes of the managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

If its getting called by the Dispose() method.

Execute()

Gets an observable that, when subscribed, executes this command.

public override IObservable<IList<TResult>> Execute()

Returns

IObservable<IList<TResult>>

An observable that will tick the single result value if and when it becomes available.

Remarks

Invoking this method will return a cold (lazy) observable that, when subscribed, will execute the logic encapsulated by the command. It is worth restating that the returned observable is lazy. Nothing will happen if you call Execute and neglect to subscribe (directly or indirectly) to the returned observable.

If no parameter value is provided, a default value of type TParam will be passed into the execution logic.

Any number of subscribers can subscribe to a given execution observable and the execution logic will only run once. That is, the result is broadcast to those subscribers.

In those cases where execution fails, there will be no result value. Instead, the failure will tick through the ThrownExceptions observable.

Execute(TParam)

Gets an observable that, when subscribed, executes this command.

public override IObservable<IList<TResult>> Execute(TParam parameter)

Parameters

parameter TParam

The parameter to pass into command execution.

Returns

IObservable<IList<TResult>>

An observable that will tick the single result value if and when it becomes available.

Remarks

Invoking this method will return a cold (lazy) observable that, when subscribed, will execute the logic encapsulated by the command. It is worth restating that the returned observable is lazy. Nothing will happen if you call Execute and neglect to subscribe (directly or indirectly) to the returned observable.

If no parameter value is provided, a default value of type TParam will be passed into the execution logic.

Any number of subscribers can subscribe to a given execution observable and the execution logic will only run once. That is, the result is broadcast to those subscribers.

In those cases where execution fails, there will be no result value. Instead, the failure will tick through the ThrownExceptions observable.

Subscribe(IObserver<IList<TResult>>)

Subscribes to execution results from this command.

public override IDisposable Subscribe(IObserver<IList<TResult>> observer)

Parameters

observer IObserver<IList<TResult>>

The observer.

Returns

IDisposable

An IDisposable that, when disposed, will unsubscribe the observer.