# SwitchSubscribeMixins

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

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

```rust
trait SwitchSubscribeMixins<S: 'static>
```

The extension methods of `SwitchSubscribeMixins` on an observable of optional values `S`.

Deviation (DEVIATIONS.md, ReactiveUI): upstream overloads `SwitchSubscribe` and `SwitchSelect`
on the element type and on the handlers; here the forms with a selector are
`switch_select` and `switch_subscribe_with*`, the forms on observables
and commands are `switch_subscribe` and
`switch_subscribe_all`, and the forms with an error and an end
handler end in `_all`. The null checks of the arguments have no counterpart.

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

## Members

- [`switch_select`](#function-switch_select)
- [`try_switch_select`](#function-try_switch_select)
- [`switch_subscribe_with`](#function-switch_subscribe_with)
- [`switch_subscribe_with_all`](#function-switch_subscribe_with_all)
- [`switch_subscribe`](#function-switch_subscribe)
- [`switch_subscribe_all`](#function-switch_subscribe_all)

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

### switch_select

```rust
fn switch_select<U: 'static>(self: &Self, selector: impl Fn(S) -> Rc<dyn IObservable<U>> + 'static) -> Rc<dyn IObservable<U>>
```

Projects each value that is not `None` to an observable and notifies the values of the
latest one (`SwitchSelect<TResult>(Func<TSource, IObservable<TResult>>)`, and the form on
commands).

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

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

### try_switch_select

```rust
fn try_switch_select<U: 'static>(self: &Self, selector: impl Fn(S) -> Result<Rc<dyn IObservable<U>>, ObservableError> + 'static) -> Rc<dyn IObservable<U>>
```

`switch_select` with a selector that may fail; a failure is the error
of the sequence (the selector that throws upstream).

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

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

### switch_subscribe_with

```rust
fn switch_subscribe_with<U: 'static>(self: &Self, selector: impl Fn(S) -> Rc<dyn IObservable<U>> + 'static, on_next: impl Fn(U) -> () + 'static) -> Rc<dyn IDisposable>
```

Subscribes `on_next` to `switch_select`; an error is ignored
(`SwitchSubscribe<TResult>(Func<TSource, IObservable<TResult>>, Action<TResult>)`).

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

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

### switch_subscribe_with_all

```rust
fn switch_subscribe_with_all<U: 'static>(self: &Self, selector: impl Fn(S) -> Rc<dyn IObservable<U>> + 'static, on_next: impl Fn(U) -> () + 'static, on_error: impl Fn(ObservableError) -> () + 'static, on_completed: impl Fn() -> () + 'static) -> Rc<dyn IDisposable>
```

Subscribes the three handlers to `switch_select`
(`SwitchSubscribe<TResult>(Func<TSource, IObservable<TResult>>, Action<TResult>,
Action<Exception>, Action)`).

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

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

### switch_subscribe

```rust
fn switch_subscribe<T: 'static>(self: &Self, on_next: impl Fn(T) -> () + 'static) -> Rc<dyn IDisposable>
where S: SwitchSource<T>
```

Subscribes `on_next` to the values of the latest observable (or command) the source
notified; an error is ignored (`SwitchSubscribe(Action<T>)` on `IObservable<IObservable<T>?>`
and on `IObservable<IReactiveCommand<TParam, TResult>?>`).

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

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

### switch_subscribe_all

```rust
fn switch_subscribe_all<T: 'static>(self: &Self, on_next: impl Fn(T) -> () + 'static, on_error: impl Fn(ObservableError) -> () + 'static, on_completed: impl Fn() -> () + 'static) -> Rc<dyn IDisposable>
where S: SwitchSource<T>
```

`switch_subscribe` with the error and end handlers
(`SwitchSubscribe(Action<T>, Action<Exception>, Action)`).

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

## Trait implementations

- [`SwitchSubscribeMixins<S>`](/docs/0.5.0/api/ferroui-reactiveui/mixins/trait-switchsubscribemixins/)

## Availability

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