# ObservedProperty

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

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

```rust
struct ObservedProperty
```

Observes properties with the behaviour of `WhenAnyValue`, one property at a time
(`ObservedProperty`).

Upstream offers it to the code that another source generator writes, which cannot rely on the
generator of `WhenAnyValue`; it takes the property as a lambda and a delegate that reads it.
Here a one-step `PropertyPath` carries both. `then` continues a path one
property further, so `x => x.A.B` is `then(create(source, a), b)`; `switch`
follows a property that holds an observable, as `WhenAnyObservable` does.

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

## Members

- [`create`](#function-create)
- [`create2`](#function-create2)
- [`create2_select`](#function-create2_select)
- [`then`](#function-then)
- [`switch`](#function-switch)

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

### create

```rust
fn create<S: 'static, V: Clone + PartialEq + 'static>(source: &Rc<S>, path: PropertyPath<Rc<S>, V>) -> Rc<dyn IObservable<V>>
```

The current value of one property, then each value it changes to, skipping repeats
(`Create(TSource, Expression<Func<TSource, TValue>>, Func<TSource, TValue>)`).

Panics when `path` has more than one step (`ArgumentException`).

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

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

### create2

```rust
fn create2<S: 'static, V1: Clone + PartialEq + 'static, V2: Clone + PartialEq + 'static>(source: &Rc<S>, path1: PropertyPath<Rc<S>, V1>, path2: PropertyPath<Rc<S>, V2>) -> Rc<dyn IObservable<(V1, V2)>>
```

The current values of two properties, then a pair each time either changes
(`Create(TSource, ..., ...)` of two properties).

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

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

### create2_select

```rust
fn create2_select<S: 'static, V1: Clone + PartialEq + 'static, V2: Clone + PartialEq + 'static, R: 'static>(source: &Rc<S>, path1: PropertyPath<Rc<S>, V1>, path2: PropertyPath<Rc<S>, V2>, selector: impl Fn(V1, V2) -> R + 'static) -> Rc<dyn IObservable<R>>
```

The values of two properties projected by `selector`
(`Create(TSource, ..., ..., Func<T1, T2, TResult>)`).

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

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

### then

```rust
fn then<P: 'static, X: Into<Option<Rc<P>>> + 'static, V: Clone + PartialEq + 'static>(parent: Rc<dyn IObservable<X>>, path: PropertyPath<Rc<P>, V>) -> Rc<dyn IObservable<V>>
```

The property of whatever object `parent` holds now, following each replacement of that
object, skipping repeats; nothing is produced while `parent` holds `None`
(`Then(IObservable<TParent?>, Expression<Func<TParent, TValue>>, Func<TParent, TValue>)`).

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

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

### switch

```rust
fn switch<V: 'static>(source: Rc<dyn IObservable<Option<Rc<dyn IObservable<V>>>>>) -> Rc<dyn IObservable<V>>
```

The values of the latest observable that a property holds; nothing is produced while it
holds `None` (`Switch(IObservable<IObservable<TValue>?>)`).

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`

## Availability

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