# AutoPersistChangeSetMixins

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

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

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

`ActOnEveryObject` of a stream of change sets (the extension members of
`IObservable<IReactiveChangeSet<TItem>>` in `AutoPersistHelperMixins`).

```
use ferroui_reactive::subjects::Subject;
use ferroui_reactiveui::{reactive_object, AutoPersistChangeSetMixins, ReactiveChange, ReactiveChangeReason, ReactiveChangeSet, ReactiveObject};
use ferroui_system::IObserver;
use std::cell::Cell;
use std::rc::Rc;

#[derive(Default)]
pub struct Item {
    reactive: ReactiveObject,
}
reactive_object!(Item);

let change_sets = Subject::<ReactiveChangeSet<Rc<Item>>>::new();
let adds = Rc::new(Cell::new(0));
let added = adds.clone();
let subscription = change_sets.as_observable().act_on_every_object(move |_| added.set(added.get() + 1), |_| {});

let item = Rc::new(Item::default());
change_sets.on_next(ReactiveChangeSet::new(vec![ReactiveChange::new(ReactiveChangeReason::Add, item, None, 0, -1)]));
assert_eq!(adds.get(), 1);
subscription.dispose();
```

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

## Members

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

<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 added and `on_remove` for each item removed by the change sets
of the stream: a replacement removes the replaced item and adds the new one, a refresh
removes the item and adds it again, and a move does nothing. The errors and the end of the
stream are ignored. Disposing the result stops watching (`ActOnEveryObject(Action<TItem>,
Action<TItem>)`).

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

## Trait implementations

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

## Availability

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