# AutoPersistHelperMixins

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

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

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

AutoPersist: saves a reactive object when its persisted properties change, throttled on an
interval (the extension members of `IReactiveObject` in `AutoPersistHelperMixins`), on its
shared handle.

The persisted properties are the ones [`DataContract`](/docs/0.5.0/api/ferroui-reactiveui/mixins/trait-datacontract/) declares; the methods of
`AutoPersistMetadataMixins` take them as explicit metadata.
Watching starts on `RxSchedulers::main_thread_scheduler`,
and the throttle runs on `RxSchedulers::task_pool_scheduler`.
An object that changes all the time may never be saved.

| Upstream | Here |
|---|---|
| `AutoPersist(Func)` | `auto_persist` |
| `AutoPersist(Func, TimeSpan?)` | `auto_persist_with_interval` |
| `AutoPersist<TDontCare>(Func, IObservable<TDontCare>, TimeSpan?)`, and without the interval | `auto_persist_with` |

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

## Members

- [`auto_persist`](#function-auto_persist)
- [`auto_persist_with_interval`](#function-auto_persist_with_interval)
- [`auto_persist_with`](#function-auto_persist_with)

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

### auto_persist

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

Saves the object with `do_persist` after its persisted properties change, with the default
interval of three seconds (`AutoPersist(Func<T, IObservable<Unit>>)`).

Returns the disposable that stops watching.

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

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

### auto_persist_with_interval

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

`auto_persist`, throttled on `interval` (the default one when `None`)
(`AutoPersist(Func, TimeSpan?)`).

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

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

### auto_persist_with

```rust
fn auto_persist_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
```

`auto_persist`, throttled on `interval`, and also whenever
`manual_save_signal` ticks, changed or not (`AutoPersist<TDontCare>(Func,
IObservable<TDontCare>, TimeSpan?)`).

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

## Trait implementations

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

## Availability

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