# BindInteractionMixins

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/mixins/trait-bindinteractionmixins/

**trait** · [`ferroui-reactiveui`](/docs/0.5.0/api/ferroui-reactiveui/) · v0.5.0

```rust
trait BindInteractionMixins<V: 'static>
```

`BindInteraction`: registers a handler of a view on the interaction a property of its view model
holds, and moves it to the new interaction when the property changes. Implemented for every
`Rc` of a view.

Upstream's source generator roots the property at the view's `ViewModel` when the view declares
one: the handler follows the view model the view displays, a new view model included, and a
view without a view model has nothing registered. `bind_interaction`
and `bind_interaction_observable` do that for a view that
declares its view model (`IViewForOf<VM>`), observed as the property `ViewModel` of the view (a view
that does not notify its changes is read once);
`bind_interaction_on` and
`bind_interaction_observable_on` root the property at a
given view model, as for a view that does not declare one.

Deviation (DEVIATIONS.md, ReactiveUI): upstream overloads `BindInteraction` by the kind of
handler (a `Task` or an observable) and resolves the root at compile time; here each is a
method of its own. The view-rooted forms leave out upstream's `viewModel` argument, which the
generated code does not read either. The expression is a `PropertyPath`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_bind_interaction.rs#L182)

## Members

- [`bind_interaction`](#function-bind_interaction)
- [`bind_interaction_observable`](#function-bind_interaction_observable)
- [`bind_interaction_on`](#function-bind_interaction_on)
- [`bind_interaction_observable_on`](#function-bind_interaction_observable_on)

<a id="function-bind_interaction"></a>

### bind_interaction

```rust
fn bind_interaction<VM, X, Fut>(self: &Self, path: PropertyPath<Rc<VM>, X>, handler: impl Fn(InteractionContextOf<X>) -> Fut + 'static) -> Rc<dyn IDisposable>
where V: IViewForOf<VM>,
      VM: 'static,
      X: InteractionValue,
      Fut: Future<Output = Result<(), ObservableError>> + 'static
```

Registers the asynchronous `handler` on the interaction `path` reads from the view's view
model (`BindInteraction(..., Func<IInteractionContext<TInput, TOutput>, Task>)`). The
handler gives a future of a `Result<(), ObservableError>`, which ends when it has handled
the question.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_bind_interaction.rs#L187)

<a id="function-bind_interaction_observable"></a>

### bind_interaction_observable

```rust
fn bind_interaction_observable<VM, X, D>(self: &Self, path: PropertyPath<Rc<VM>, X>, handler: impl Fn(InteractionContextOf<X>) -> Rc<dyn IObservable<D>> + 'static) -> Rc<dyn IDisposable>
where V: IViewForOf<VM>,
      VM: 'static,
      X: InteractionValue,
      D: 'static
```

Registers the observable-based `handler` on the interaction `path` reads from the view's
view model; the handler has finished when its observable ends
(`BindInteraction(..., Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_bind_interaction.rs#L197)

<a id="function-bind_interaction_on"></a>

### bind_interaction_on

```rust
fn bind_interaction_on<VM, X, Fut>(self: &Self, view_model: Option<Rc<VM>>, path: PropertyPath<Rc<VM>, X>, handler: impl Fn(InteractionContextOf<X>) -> Fut + 'static) -> Rc<dyn IDisposable>
where VM: 'static,
      X: InteractionValue,
      Fut: Future<Output = Result<(), ObservableError>> + 'static
```

`bind_interaction` rooted at `view_model`; no view model
registers nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_bind_interaction.rs#L210)

<a id="function-bind_interaction_observable_on"></a>

### bind_interaction_observable_on

```rust
fn bind_interaction_observable_on<VM, X, D>(self: &Self, view_model: Option<Rc<VM>>, path: PropertyPath<Rc<VM>, X>, handler: impl Fn(InteractionContextOf<X>) -> Rc<dyn IObservable<D>> + 'static) -> Rc<dyn IDisposable>
where VM: 'static,
      X: InteractionValue,
      D: 'static
```

`bind_interaction_observable` rooted at `view_model`;
no view model registers nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_bind_interaction.rs#L223)

## Trait implementations

- [`BindInteractionMixins<V>`](/docs/0.5.0/api/ferroui-reactiveui/binding/mixins/trait-bindinteractionmixins/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
