# AutoPersistCollectionMixins

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/mixins/trait-autopersistcollectionmixins/

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

```rust
trait AutoPersistCollectionMixins<T: IReactiveObject>
```

AutoPersist for each item of a collection, and `ActOnEveryObject` (the extension members of
`ObservableCollection<TItem>` in `AutoPersistHelperMixins`): an item is saved while it is in
the collection, and no longer after it was removed.

| Upstream | Here |
|---|---|
| `AutoPersistCollection(Func)` | `auto_persist_collection` |
| `AutoPersistCollection(Func, TimeSpan?)` | `auto_persist_collection_with_interval` |
| `AutoPersistCollection<TDontCare>(Func, IObservable<TDontCare>, TimeSpan?)`, and without the interval | `auto_persist_collection_with` |
| `ActOnEveryObject(Action<TItem>, Action<TItem>)` | `act_on_every_object` |

The overloads with explicit metadata are those of
`AutoPersistCollectionMetadataMixins`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/mixins/auto_persist_helper_mixins.rs#L196)

## Members

- [`auto_persist_collection`](#function-auto_persist_collection)
- [`auto_persist_collection_with_interval`](#function-auto_persist_collection_with_interval)
- [`auto_persist_collection_with`](#function-auto_persist_collection_with)
- [`act_on_every_object`](#function-act_on_every_object)

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

### auto_persist_collection

```rust
fn auto_persist_collection(self: &Self, do_persist: impl Fn(Rc<T>) -> Rc<dyn IObservable<()>> + 'static) -> Rc<dyn IDisposable>
where T: DataContract
```

Persists each item with the default interval (`AutoPersistCollection(Func)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/mixins/auto_persist_helper_mixins.rs#L198)

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

### auto_persist_collection_with_interval

```rust
fn auto_persist_collection_with_interval(self: &Self, do_persist: impl Fn(Rc<T>) -> Rc<dyn IObservable<()>> + 'static, interval: Option<Duration>) -> Rc<dyn IDisposable>
where T: DataContract
```

Persists each item, throttled on `interval` (`AutoPersistCollection(Func, TimeSpan?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/mixins/auto_persist_helper_mixins.rs#L203)

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

### auto_persist_collection_with

```rust
fn auto_persist_collection_with<S: 'static>(self: &Self, do_persist: impl Fn(Rc<T>) -> Rc<dyn IObservable<()>> + 'static, manual_save_signal: Rc<dyn IObservable<S>>, interval: Option<Duration>) -> Rc<dyn IDisposable>
where T: DataContract
```

Persists each item, throttled on `interval`, and whenever `manual_save_signal` ticks
(`AutoPersistCollection<TDontCare>(Func, IObservable<TDontCare>, TimeSpan?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/mixins/auto_persist_helper_mixins.rs#L209)

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

### act_on_every_object

```rust
fn act_on_every_object(self: &Self, on_add: impl Fn(Rc<T>) -> () + 'static, on_remove: impl Fn(Rc<T>) -> () + 'static) -> Rc<dyn IDisposable>
```

Calls `on_add` for each item now and for each item added, and `on_remove` for each item
removed; a reset removes the items there were and adds the items there are. Disposing the
result stops watching and calls `on_remove` for every item (`ActOnEveryObject`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/mixins/auto_persist_helper_mixins.rs#L221)

## Trait implementations

- [`AutoPersistCollectionMixins<T>`](/docs/0.5.0/api/ferroui-reactiveui/mixins/trait-autopersistcollectionmixins/)

## Availability

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