# CollectionChangedEventManager

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/utils/struct-collectionchangedeventmanager/

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

```rust
struct CollectionChangedEventManager
```

Dispatches the changes of notifying collections to weakly held
listeners. A collection is subscribed to once, however many listeners it
has.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/utils/collection_changed_event_manager.rs#L73)

## Members

- [`add_listener`](#function-add_listener)
- [`remove_listener`](#function-remove_listener)

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

### add_listener

```rust
fn add_listener(collection: &ItemsSource, listener: Weak<dyn ICollectionChangedListener>)
```

Adds a listener to a collection. Panics if the listener is already
registered for the collection. Does nothing for a collection that
does not notify.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/utils/collection_changed_event_manager.rs#L79)

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

### remove_listener

```rust
fn remove_listener(collection: &ItemsSource, listener: &Weak<dyn ICollectionChangedListener>)
```

Removes a listener from a collection. Panics if the listener is not
registered for the collection.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/utils/collection_changed_event_manager.rs#L123)

## 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`

## Availability

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