# EventObservable

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

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

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

The value of a property on subscription, then again each time its change event is raised
(`EventObservable<T>`).

The value comes from the getter, which is read on subscription and on every raise, so the
arguments of the event are ignored. The value read on subscription is always delivered; with
`distinct_until_changed`, a later value equal to the last one delivered is dropped. A getter that
panics on subscription detaches the handler before the panic propagates; one that panics while
the event is raised propagates to whoever raised it. The sequence never completes.

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

## Members

- [`new`](#function-new)

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

### new

```rust
fn new(add_handler: impl Fn(Rc<dyn Fn() -> ()>) -> () + 'static, remove_handler: impl Fn(Rc<dyn Fn() -> ()>) -> () + 'static, getter: impl Fn() -> T + 'static, distinct_until_changed: bool) -> Self
```

The values `getter` reads, on subscription and each time the event that `add_handler`
subscribes a handler to (and `remove_handler` unsubscribes it from) is raised
(`EventObservable(Action<EventHandler>, Action<EventHandler>, Func<T>, bool)`). A handler is
an `Rc<dyn Fn()>` (`EventHandler`), compared by identity: the handler given to
`remove_handler` is the one given to `add_handler`.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`SubscribeGuard<T>`](/docs/0.5.0/api/ferroui-base/reactive/use-subscribeguard/)
- [`IObservable<T>`](/docs/0.5.0/api/ferroui-base/reactive/use-iobservable/)
- `Debug`

## Availability

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