# FuncAddEventHandler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-xaml-interactivity/struct-funcaddeventhandler/

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

```rust
struct FuncAddEventHandler<TTarget, TEventArgs, TToken = std::rc::Rc<dyn IDisposable>>
```

An [`IAddEventHandler`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-iaddeventhandler/) for the event `name` of sources of type `TTarget`, from a function
that subscribes a handler and a function that removes it.

`TTarget` is the handle of the source (`Ref<Button>`, `Rc<Model>`). Deviation (DEVIATIONS.md,
Behaviors): the reference removes a handler by delegate identity; a subscription of the port
returns a token (`TToken`: a routed event handler token, a disposable), which is what `remove`
takes.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/events/handlers/func_event_handler.rs#L52)

## Members

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

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

### new

```rust
fn new(name: &str, add: impl Fn(&TTarget, EventHandler<TEventArgs>) -> TToken + 'static, remove: impl Fn(&TTarget, TToken) -> () + 'static) -> Self
```

Creates the handler of the event `name`: `add` subscribes a handler to a source, `remove`
removes it with the token `add` returned.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/events/handlers/func_event_handler.rs#L66)

## Trait implementations

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

## Availability

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