Class InteractionBindingMixins
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
This class provides extension methods for the ReactiveUI view binding mechanism.
- Inheritance
-
Interaction
Binding Mixins
Examples
this.WhenActivated(disposables =>
{
this.BindInteraction(ViewModel, vm => vm.ShowDialog, HandleDialogAsync)
.DisposeWith(disposables);
});
Remarks
Interaction bindings are usually established within a view's activation block to ensure registrations are disposed when the view is no longer visible. The helpers resolve the IInteraction<TInput, TOutput> on the view model via an expression and hook it to a handler that can await UI prompts such as dialogs.
Methods
BindInteraction<TViewModel, TView, TInput, TOutput>(TView, TViewModel?, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>>, Func<IInteractionContext<TInput, TOutput>, Task>)
Binds the IInteraction<TInput, TOutput> on a ViewModel to the specified handler.
[RequiresDynamicCode("BindInteraction uses expression binding which requires dynamic code generation")]
[RequiresUnreferencedCode("BindInteraction uses expression binding which may require unreferenced code")]
public static IDisposable BindInteraction<TViewModel, TView, TInput, TOutput>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> propertyName, Func<IInteractionContext<TInput, TOutput>, Task> handler) where TViewModel : class where TView : class, IViewFor
Parameters
viewTViewThe view to bind to.
viewModelTViewModel The view model to bind to.
propertyNameExpression<Func<TViewModel, IInteraction<TInput, TOutput>>>The name of the property on the View Model.
handlerFunc<IInteractionContext <TInput, TOutput>, Task>The handler.
Returns
- IDisposable
An object that when disposed, disconnects the binding.
Type Parameters
TViewModelThe type of the view model.
TViewThe type of the view being bound.
TInputThe interaction's input type.
TOutputThe interaction's output type.
BindInteraction<TViewModel, TView, TInput, TOutput, TDontCare>(TView, TViewModel?, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>>, Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>>)
Binds the IInteraction<TInput, TOutput> on a ViewModel to the specified handler.
[RequiresDynamicCode("BindInteraction uses expression binding which requires dynamic code generation")]
[RequiresUnreferencedCode("BindInteraction uses expression binding which may require unreferenced code")]
public static IDisposable BindInteraction<TViewModel, TView, TInput, TOutput, TDontCare>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, IInteraction<TInput, TOutput>>> propertyName, Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>> handler) where TViewModel : class where TView : class, IViewFor
Parameters
viewTViewThe view to bind to.
viewModelTViewModel The view model to bind to.
propertyNameExpression<Func<TViewModel, IInteraction<TInput, TOutput>>>The name of the property on the View Model.
handlerFunc<IInteractionContext <TInput, TOutput>, IObservable<TDontCare>>The handler.
Returns
- IDisposable
An object that when disposed, disconnects the binding.
Type Parameters
TViewModelThe type of the view model.
TViewThe type of the view being bound.
TInputThe interaction's input type.
TOutputThe interaction's output type.
TDontCareThe interaction's signal type.