# ObservableAsPropertyHelper

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

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

```rust
struct ObservableAsPropertyHelper<T: 'static>
```

Backs a read-only output property with an observable: the property reports each new value
through the callbacks it was created with, so that its owner raises its own change
notifications (`ObservableAsPropertyHelper<T>`).

It is normally made by `to_property`,
whose callbacks raise the owner's notifications for the named property; it can also be made
directly with callbacks of one's own. A view model stores it (in a `OnceCell` or a
`RefCell<Option<..>>`) and reads `value` in its getter.

Values equal to the previous one are skipped. Without a scheduler, or with the immediate one,
each value is delivered at once; a value produced while another is being delivered waits for
that delivery to end, so the callbacks never nest.

The helper is a shared handle: its clones are the same helper.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L70)

## Members

- [`new`](#function-new)
- [`with_initial_value`](#function-with_initial_value)
- [`with_initial_value_on`](#function-with_initial_value_on)
- [`with_initial_value_deferred`](#function-with_initial_value_deferred)
- [`with_changing`](#function-with_changing)
- [`with_options`](#function-with_options)
- [`create`](#function-create)
- [`default_with_initial_value`](#function-default_with_initial_value)
- [`default_with_initial_value_on`](#function-default_with_initial_value_on)
- [`value`](#function-value)
- [`is_subscribed`](#function-is_subscribed)
- [`thrown_exceptions`](#function-thrown_exceptions)

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

### new

```rust
fn new(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static) -> Self
where T: Default
```

A helper that follows `observable` from the default value of `T`, running `on_changed`
with each new value (`ObservableAsPropertyHelper(IObservable<T?>, Action<T?>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L83)

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

### with_initial_value

```rust
fn with_initial_value(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, initial_value: T) -> Self
```

A helper that starts from `initial_value`
(`ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, T?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L92)

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

### with_initial_value_on

```rust
fn with_initial_value_on(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, initial_value: T, scheduler: Option<Rc<dyn IScheduler>>) -> Self
```

A helper that starts from `initial_value` and delivers its values on `scheduler`
(`ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, T?, ISequencer?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L98)

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

### with_initial_value_deferred

```rust
fn with_initial_value_deferred(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, initial_value: T, defer_subscription: bool) -> Self
```

A helper that starts from `initial_value` and, when `defer_subscription` is set, subscribes
to `observable` on the first read of `value`
(`ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, T?, bool)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L110)

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

### with_changing

```rust
fn with_changing(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, on_changing: impl Fn(T) -> () + 'static) -> Self
where T: Default
```

A helper with a callback run before each new value is stored, as well as the one run after
(`ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, Action<T?>?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L121)

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

### with_options

```rust
fn with_options(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, on_changing: Option<Rc<dyn Fn(T) -> ()>>, initial_value: ObservableAsPropertyInitialValue<T>, defer_subscription: bool, scheduler: Option<Rc<dyn IScheduler>>) -> Self
```

The helper with every option: `on_changing` runs before each new value is stored and
`on_changed` after; `initial_value` is a value or a factory; `defer_subscription` delays the
subscription to the first read of `value`; `scheduler` delivers the values
(the other constructors of upstream, which this one covers).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L132)

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

### create

```rust
fn create<O: 'static>(observable: Rc<dyn IObservable<T>>, owner: &Rc<O>, on_changed: impl Fn(&Rc<O>, T) -> () + 'static, on_changing: Option<Rc<dyn Fn(&Rc<O>, T) -> ()>>, initial_value: ObservableAsPropertyInitialValue<T>, defer_subscription: bool, scheduler: Option<Rc<dyn IScheduler>>) -> Self
```

A helper whose callbacks take its owner, which the helper holds weakly: once the owner is
dropped, the callbacks are not run (`Create(IObservable<T?>, object, Action<object?, T?>,
Action<object?, T?>?, T?, bool, ISequencer?)`, the factory that `ToProperty` uses).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L146)

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

### default_with_initial_value

```rust
fn default_with_initial_value(initial_value: T) -> Self
```

A helper that holds `initial_value` and never changes (`Default(T?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L173)

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

### default_with_initial_value_on

```rust
fn default_with_initial_value_on(initial_value: T, scheduler: Option<Rc<dyn IScheduler>>) -> Self
```

A helper that holds `initial_value`, delivered on `scheduler`, and never changes
(`Default(T?, ISequencer?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L179)

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

### value

```rust
fn value(self: &Self) -> T
```

The last value of the property; a deferred helper subscribes on its first read (`Value`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L200)

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

### is_subscribed

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

Whether the helper has subscribed to its source (`IsSubscribed`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L205)

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

### thrown_exceptions

```rust
fn thrown_exceptions(self: &Self) -> Rc<dyn IObservable<ObservableError>>
```

The errors of the source (`ThrownExceptions`). While it has no observer, an error goes to
`RxState::default_exception_handler`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/observable_as_property_helper.rs#L211)

## 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`
- `Default`
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)

## Availability

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