# ViewForMixins

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/activation/trait-viewformixins/

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

```rust
trait ViewForMixins
```

The activation of views (the extension members of `IActivatableView` in `ViewForMixins`),
for the shared handle of a view.

The activation of a view comes from the registered
[`IActivationForViewFetcher`](/docs/0.5.0/api/ferroui-reactiveui/activation/trait-iactivationforviewfetcher/) with the highest affinity for it; a view that no fetcher
handles panics (`ArgumentException`). While the view is active, the view model it shows (when
the view is an [`IViewFor`](/docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/trait-iviewfor/)) is activated too, when it is an [`IActivatableViewModel`](/docs/0.5.0/api/ferroui-reactiveui/interfaces/trait-iactivatableviewmodel/):
setting another view model deactivates the old one and activates the new one.

Upstream overloads `WhenActivated` on the shape of the block and on the extra arguments; here
each shape has a name:

| Upstream | Here |
|---|---|
| `WhenActivated(Func<IEnumerable<IDisposable>>)` | `when_activated` |
| `WhenActivated(Action<Action<IDisposable>>)` | `when_activated_register` |
| `WhenActivated(Action<ActivationDisposables>)` | `when_activated_disposables` |
| `WhenActivated()` | `when_activated_empty` |
| the same with `IViewFor? view` | `..._for_view` |
| the same with `IObservable<object?> viewModelChanged` | `..._with_view_model_changed` |

Each returns a disposable that ends the activation of the view and disposes what the block
set up.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L83)

## Members

- [`when_activated`](#function-when_activated)
- [`when_activated_for_view`](#function-when_activated_for_view)
- [`when_activated_register`](#function-when_activated_register)
- [`when_activated_register_for_view`](#function-when_activated_register_for_view)
- [`when_activated_disposables`](#function-when_activated_disposables)
- [`when_activated_disposables_for_view`](#function-when_activated_disposables_for_view)
- [`when_activated_empty`](#function-when_activated_empty)
- [`when_activated_with_view_model_changed`](#function-when_activated_with_view_model_changed)
- [`when_activated_register_with_view_model_changed`](#function-when_activated_register_with_view_model_changed)
- [`when_activated_disposables_with_view_model_changed`](#function-when_activated_disposables_with_view_model_changed)
- [`when_activated_empty_with_view_model_changed`](#function-when_activated_empty_with_view_model_changed)
- [`get_is_design_mode`](#function-get_is_design_mode)

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

### when_activated

```rust
fn when_activated(self: &Self, block: impl Fn() -> Vec<Rc<dyn IDisposable>> + 'static) -> Rc<dyn IDisposable>
```

Runs `block` each time the view is activated; what it returns is disposed when the view
is deactivated (`WhenActivated(Func<IEnumerable<IDisposable>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L86)

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

### when_activated_for_view

```rust
fn when_activated_for_view(self: &Self, block: impl Fn() -> Vec<Rc<dyn IDisposable>> + 'static, view: Option<Rc<dyn IViewFor>>) -> Rc<dyn IDisposable>
```

`when_activated` where the view model activated with the view is
the one of `view` rather than of this view (`WhenActivated(Func<IEnumerable<IDisposable>>,
IViewFor?)`), for a view hosted apart from its view model.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L91)

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

### when_activated_register

```rust
fn when_activated_register(self: &Self, block: impl Fn(&dyn Fn(Rc<dyn IDisposable>) -> ()) -> () + 'static) -> Rc<dyn IDisposable>
```

Runs `block` each time the view is activated; the block registers what to dispose on
deactivation with the function it is given (`WhenActivated(Action<Action<IDisposable>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L99)

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

### when_activated_register_for_view

```rust
fn when_activated_register_for_view(self: &Self, block: impl Fn(&dyn Fn(Rc<dyn IDisposable>) -> ()) -> () + 'static, view: Option<Rc<dyn IViewFor>>) -> Rc<dyn IDisposable>
```

`when_activated_register` with the view whose view model
is activated (`WhenActivated(Action<Action<IDisposable>>, IViewFor)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L103)

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

### when_activated_disposables

```rust
fn when_activated_disposables(self: &Self, block: impl Fn(&Rc<ActivationDisposables>) -> () + 'static) -> Rc<dyn IDisposable>
```

Runs `block` each time the view is activated with the `ActivationDisposables` that are
disposed on deactivation (`WhenActivated(Action<ActivationDisposables>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L111)

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

### when_activated_disposables_for_view

```rust
fn when_activated_disposables_for_view(self: &Self, block: impl Fn(&Rc<ActivationDisposables>) -> () + 'static, view: Option<Rc<dyn IViewFor>>) -> Rc<dyn IDisposable>
```

`when_activated_disposables` with the view whose view
model is activated (`WhenActivated(Action<ActivationDisposables>, IViewFor?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L115)

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

### when_activated_empty

```rust
fn when_activated_empty(self: &Self) -> Rc<dyn IDisposable>
```

Activates the view, and with it its view model, without a block of its own
(`WhenActivated()`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L123)

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

### when_activated_with_view_model_changed

```rust
fn when_activated_with_view_model_changed(self: &Self, block: impl Fn() -> Vec<Rc<dyn IDisposable>> + 'static, view_model_changed: Rc<dyn IObservable<ViewModelValue>>) -> Rc<dyn IDisposable>
```

`when_activated`, where the view model to activate is the latest
value of `view_model_changed`, which emits the current view model and every later one
(`WhenActivated(Func<IEnumerable<IDisposable>>, IObservable<object?>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L128)

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

### when_activated_register_with_view_model_changed

```rust
fn when_activated_register_with_view_model_changed(self: &Self, block: impl Fn(&dyn Fn(Rc<dyn IDisposable>) -> ()) -> () + 'static, view_model_changed: Rc<dyn IObservable<ViewModelValue>>) -> Rc<dyn IDisposable>
```

`when_activated_register` with the view model's changes
(`WhenActivated(Action<Action<IDisposable>>, IObservable<object?>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L136)

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

### when_activated_disposables_with_view_model_changed

```rust
fn when_activated_disposables_with_view_model_changed(self: &Self, block: impl Fn(&Rc<ActivationDisposables>) -> () + 'static, view_model_changed: Rc<dyn IObservable<ViewModelValue>>) -> Rc<dyn IDisposable>
```

`when_activated_disposables` with the view model's
changes (`WhenActivated(Action<ActivationDisposables>, IObservable<object?>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L144)

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

### when_activated_empty_with_view_model_changed

```rust
fn when_activated_empty_with_view_model_changed(self: &Self, view_model_changed: Rc<dyn IObservable<ViewModelValue>>) -> Rc<dyn IDisposable>
```

`when_activated_empty` with the view model's changes
(`WhenActivated(IObservable<object?>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L152)

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

### get_is_design_mode

```rust
fn get_is_design_mode(self: &Self) -> bool
```

Whether the view is being loaded by a designer (`GetIsDesignMode()`): false; the
integration of a toolkit can tell otherwise for its views.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/activation/view_for_mixins.rs#L156)

## Trait implementations

- [`ViewForMixins`](/docs/0.5.0/api/ferroui-reactiveui/activation/trait-viewformixins/)

## Availability

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