# WeakEventHandlerTarget

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/trait-weakeventhandlertarget/

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

```rust
trait WeakEventHandlerTarget<A: WeakEventArgs + ?Sized>
```

The events of a type, found by name: what the managed original looks up
through reflection on the target type.

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

## Members

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

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

### add_event_handler

```rust
fn add_event_handler(self: &Self, event_name: &str, handler: Rc<WeakEventHandler<A>>) -> Option<Box<dyn FnOnce() -> ()>>
```

Adds `handler` to the event named `event_name` and returns the action
that removes it, or `None` if the type has no such event.

The action must not hold the target strongly: the target holds the
subscription through the handler, and the subscription holds the
action.

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

## Availability

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