Class ReactiveCommandMixins
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
Extension methods associated with the ReactiveCommand class.
- Inheritance
-
Reactive
Command Mixins
Examples
this.WhenAnyValue(x => x.ViewModel.SaveCommand)
.Select(_ => Unit.Default)
.InvokeCommand(ViewModel.SaveCommand)
.DisposeWith(disposables);
Remarks
InvokeCommand is typically chained after an IObservable<T> that represents user intent. It
forwards each value into an ICommand once Can
Methods
InvokeCommand<T>(IObservable<T>, ICommand?)
A utility method that will pipe an Observable to an ICommand (i.e. it will first call its CanExecute with the provided value, then if the command can be executed, Execute() will be called).
Parameters
itemIObservable<T>The source observable to pipe into the command.
commandICommandThe command to be executed.
Returns
- IDisposable
An object that when disposes, disconnects the Observable from the command.
Type Parameters
TThe type.
InvokeCommand<T, TResult>(IObservable<T>, ReactiveCommandBase<T, TResult>?)
A utility method that will pipe an Observable to an ICommand (i.e. it will first call its CanExecute with the provided value, then if the command can be executed, Execute() will be called).
public static IDisposable InvokeCommand<T, TResult>(this IObservable<T> item, ReactiveCommandBase<T, TResult>? command)
Parameters
itemIObservable<T>The source observable to pipe into the command.
commandReactiveCommand <T, TResult>Base The command to be executed.
Returns
- IDisposable
An object that when disposes, disconnects the Observable from the command.
Type Parameters
TThe type.
TResultThe result type.
InvokeCommand<T, TTarget>(IObservable<T>, TTarget?, Expression<Func<TTarget, ICommand?>>)
A utility method that will pipe an Observable to an ICommand (i.e. it will first call its CanExecute with the provided value, then if the command can be executed, Execute() will be called).
[RequiresDynamicCode("InvokeCommand uses WhenAnyValue which requires dynamic code generation for expression tree analysis.")]
[RequiresUnreferencedCode("InvokeCommand uses WhenAnyValue which may reference members that could be trimmed.")]
public static IDisposable InvokeCommand<T, TTarget>(this IObservable<T> item, TTarget? target, Expression<Func<TTarget, ICommand?>> commandProperty) where TTarget : class
Parameters
itemIObservable<T>The source observable to pipe into the command.
targetTTargetThe root object which has the Command.
commandPropertyExpression<Func<TTarget, ICommand>>The expression to reference the Command.
Returns
- IDisposable
An object that when disposes, disconnects the Observable from the command.
Type Parameters
TThe type.
TTargetThe target type.
InvokeCommand<T, TResult, TTarget>(IObservable<T>, TTarget?, Expression<Func<TTarget, ReactiveCommandBase<T, TResult>?>>)
A utility method that will pipe an Observable to an ICommand (i.e. it will first call its CanExecute with the provided value, then if the command can be executed, Execute() will be called).
[RequiresDynamicCode("InvokeCommand uses WhenAnyValue which requires dynamic code generation for expression tree analysis.")]
[RequiresUnreferencedCode("InvokeCommand uses WhenAnyValue which may reference members that could be trimmed.")]
public static IDisposable InvokeCommand<T, TResult, TTarget>(this IObservable<T> item, TTarget? target, Expression<Func<TTarget, ReactiveCommandBase<T, TResult>?>> commandProperty) where TTarget : class
Parameters
itemIObservable<T>The source observable to pipe into the command.
targetTTargetThe root object which has the Command.
commandPropertyExpression<Func<TTarget, ReactiveCommand <T, TResult>>>Base The expression to reference the Command.
Returns
- IDisposable
An object that when disposes, disconnects the Observable from the command.
Type Parameters
TThe type.
TResultThe result type.
TTargetThe target type.