# WeakEvents

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-weakevents/

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

```rust
struct WeakEvents
```

The weak events of the framework's notification contracts.

Each event is a per-thread static, as everything the event refers to
belongs to one thread; an accessor returns the event of the calling
thread.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_events.rs#L23)

## Members

- [`collection_changed`](#function-collection_changed)
- [`thread_safe_property_changed`](#function-thread_safe_property_changed)
- [`ferro_property_changed`](#function-ferro_property_changed)
- [`command_can_execute_changed`](#function-command_can_execute_changed)
- [`subscribe_command_can_execute_changed`](#function-subscribe_command_can_execute_changed)

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

### collection_changed

```rust
fn collection_changed() -> Rc<WeakEvent<Rc<dyn INotifyCollectionChanged>, CollectionChange>>
```

Represents CollectionChanged event from `INotifyCollectionChanged`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_events.rs#L83)

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

### thread_safe_property_changed

```rust
fn thread_safe_property_changed() -> Rc<WeakEvent<Rc<dyn INotifyPropertyChanged>, str>>
```

Represents PropertyChanged event from `INotifyPropertyChanged` with
auto-dispatching to the UI thread.

A model object is bound to the thread it was created on (it is held
through `Rc`), so its notifications are raised on that thread and are
forwarded there directly.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_events.rs#L93)

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

### ferro_property_changed

```rust
fn ferro_property_changed() -> Rc<WeakEvent<Ref<FerroObject>, FerroPropertyChangedEventArgs<'static>>>
```

Represents PropertyChanged event from `FerroObject`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_events.rs#L98)

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

### command_can_execute_changed

```rust
fn command_can_execute_changed() -> Rc<WeakEvent<Rc<dyn ICommand>, EventArgs>>
```

Represents CanExecuteChanged event from `ICommand`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_events.rs#L103)

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

### subscribe_command_can_execute_changed

```rust
fn subscribe_command_can_execute_changed<T: ObjectType>(command: &Rc<dyn ICommand>, subscriber: &Ref<T>, handler: fn(&T) -> ()) -> Rc<dyn IDisposable>
```

Subscribes `subscriber` to the "can execute changed" event of
`command`. `handler` is called with the subscriber each time the
event is raised.

Not in the original: the command sources (button, menu item, split
button, native menu item) subscribe through this handle-based form.

The subscriber keeps the returned handle (normally in a field). The
subscription ends when the handle is disposed, when the handle is
dropped (so with the subscriber), or, if the handle is kept alive
elsewhere, the first time the event is raised after the subscriber
is gone. The command never holds a strong reference to the
subscriber.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_events.rs#L120)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

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