# PropertyChain

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/binding/struct-propertychain/

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

```rust
struct PropertyChain<S, V>
```

A path from an object to a value through properties, any step of which may be null (the
expression of `WhenPropertyChanged` and `WhenValueChanged`, split into its
`ObservablePropertyPart`s).

Its value is `None` when a step is null (upstream's `UnobtainableValue`). Each step that
notifies its changes is observed on the object it is read from; when a step changes, the
steps after it are observed again on the new objects, and none is observed past a null step.

```
use ferroui_dynamic_data::binding::PropertyChain;
use ferroui_system::component_model::{INotifyPropertyChanged, PropertyPath};
use ferroui_system::events::Event;
use std::cell::{Cell, RefCell};
use std::rc::Rc;

struct Child { age: Cell<i32>, changed: Event<str> }
impl Child { fn age(&self) -> i32 { self.age.get() } }
impl INotifyPropertyChanged for Child { fn property_changed(&self) -> &Event<str> { &self.changed } }

struct Parent { child: RefCell<Option<Rc<Child>>>, changed: Event<str> }
impl Parent { fn child(&self) -> Option<Rc<Child>> { self.child.borrow().clone() } }
impl INotifyPropertyChanged for Parent { fn property_changed(&self) -> &Event<str> { &self.changed } }

// x => x.Child!.Age
let chain = PropertyChain::nullable(ferroui_system::prop!(Parent => child)).then(ferroui_system::prop!(Child => age));
let parent = Rc::new(Parent { child: RefCell::new(None), changed: Event::new() });
assert_eq!(chain.get(&parent), None);
*parent.child.borrow_mut() = Some(Rc::new(Child { age: Cell::new(3), changed: Event::new() }));
assert_eq!(chain.get(&parent), Some(3));
assert_eq!(chain.path(), "Child.Age");
```

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L68)

## Members

- [`new`](#function-new)
- [`nullable`](#function-nullable)
- [`names`](#function-names)
- [`path`](#function-path)
- [`get`](#function-get)
- [`getter`](#function-getter)
- [`observe`](#function-observe)
- [`then`](#function-then)
- [`then_nullable`](#function-then_nullable)
- [`map`](#function-map)

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

### new

```rust
fn new(path: PropertyPath<S, V>) -> Self
```

The chain of a path whose steps are never null.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L82)

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

### nullable

```rust
fn nullable(path: PropertyPath<S, Option<V>>) -> Self
```

The chain of a path whose last step may be null (`x => x.Child!`): its value is `None`
when the step is.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L90)

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

### names

```rust
fn names(self: &Self) -> &[String]
```

The names of the properties along the chain.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L97)

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

### path

```rust
fn path(self: &Self) -> String
```

The chain as text, `Child.Age`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L102)

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

### get

```rust
fn get(self: &Self, source: &S) -> Option<V>
```

The value of the chain on `source`; `None` when a step is null (the walk of
`ReadCurrent`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L108)

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

### getter

```rust
fn getter(self: &Self) -> Rc<dyn Fn(&S) -> Option<V>>
```

The getter of the chain.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L113)

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

### observe

```rust
fn observe(self: &Self, source: &S, changed: Rc<dyn Fn() -> ()>) -> Rc<dyn IDisposable>
```

Runs `changed` whenever the value of the chain on `source` may have changed, until the
result is disposed (the subscriptions of the levels of `DeepChainSubscription`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L119)

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

### then

```rust
fn then<P: IntoPropertyChain<V>>(self: Self, next: P) -> PropertyChain<S, <P as >::Value>
where S: Clone,
      V: Clone,
      <P as >::Value: 'static
```

The chain that continues with `next` from the value of this one (`x => x.A.B`): when the
object of this step changes, the steps of `next` are observed on the new object, and on
none when it is null.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L126)

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

### then_nullable

```rust
fn then_nullable<W: 'static>(self: Self, next: PropertyPath<V, Option<W>>) -> PropertyChain<S, W>
where S: Clone,
      V: Clone
```

`then` with a step that may be null (`x => x.A!.B`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L174)

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

### map

```rust
fn map<W: 'static>(self: Self, convert: impl Fn(V) -> W + 'static) -> PropertyChain<S, W>
```

The chain whose value is converted by `convert` (an expression's `Convert` node, such as
`x => (decimal)x.Amount` or `x => ((IHasAge)x.Child).Age`); the steps observed are the
same.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/binding/observable_property_part.rs#L185)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Clone`
- [`IntoPropertyChain<S>`](/docs/0.5.0/api/ferroui-dynamic-data/binding/trait-intopropertychain/)

## Availability

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