# Event

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/events/struct-event/

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

```rust
struct Event<A: ?Sized>
```

A multicast event of a model object: the equivalent of a managed `event`
member on a type that is not part of the class hierarchy.

Handlers are identified by the token returned from `add`.
Raising works on a snapshot, so handlers may add or remove handlers.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L9)

## Members

- [`new`](#function-new)
- [`snapshot`](#function-snapshot)
- [`add`](#function-add)
- [`remove`](#function-remove)
- [`has_handlers`](#function-has_handlers)
- [`handler_count`](#function-handler_count)
- [`raise`](#function-raise)

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

### new

```rust
const fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L20)

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

### snapshot

```rust
fn snapshot(self: &Self) -> HandlerSnapshot<dyn Fn(&A) -> ()>
```

The current handlers with their tokens; later changes do not affect
it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L26)

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

### add

```rust
fn add(self: &Self, handler: Rc<dyn Fn(&A) -> ()>) -> u64
```

Adds a handler; returns the token that removes it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L31)

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

### remove

```rust
fn remove(self: &Self, token: u64) -> bool
```

Removes a handler. Returns false if the token is unknown.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L36)

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

### has_handlers

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

Whether any handler is subscribed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L41)

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

### handler_count

```rust
fn handler_count(self: &Self) -> usize
```

The number of subscribed handlers.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L46)

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

### raise

```rust
fn raise(self: &Self, args: &A)
```

Invokes the handlers.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/event.rs#L51)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `Default`

## Availability

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