# ObservableCache

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/cache/struct-observablecache/

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

```rust
struct ObservableCache<T, K>
```

A cache whose edits and contents can be observed (`ObservableCache<TObject, TKey>`): the core
of `SourceCache`, and the cache of `AsObservableCache`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L110)

## Members

- [`new`](#function-new)
- [`without_key_selector`](#function-without_key_selector)
- [`from_source`](#function-from_source)
- [`key_selector`](#function-key_selector)
- [`update_from_source`](#function-update_from_source)
- [`update_from_intermediate`](#function-update_from_intermediate)
- [`suspend_count`](#function-suspend_count)
- [`suspend_notifications`](#function-suspend_notifications)

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

### new

```rust
fn new(key_selector: impl Fn(&T) -> K + 'static) -> Self
```

An empty cache whose items are keyed by `key_selector`
(`ObservableCache(Func<TObject, TKey>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L142)

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

### without_key_selector

```rust
fn without_key_selector() -> Self
```

A cache without a key selector, for edits that give the keys
(`ObservableCache(Func<TObject, TKey>? = null)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L148)

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

### from_source

```rust
fn from_source<C: IChangeSet<T, K>>(source: Rc<dyn IObservable<C>>) -> Self
```

A cache that applies the change sets of `source` (`ObservableCache(IObservable<IChangeSet>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L153)

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

### key_selector

```rust
fn key_selector(self: &Self) -> Option<&KeySelector<T, K>>
```

The key selector of the cache.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L184)

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

### update_from_source

```rust
fn update_from_source(self: &Self, update: impl FnOnce(&mut dyn ISourceUpdater<T, K>) -> ())
```

Runs an edit with the cache's key selector (`UpdateFromSource`); the changes are delivered
once the outermost edit ends.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L190)

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

### update_from_intermediate

```rust
fn update_from_intermediate(self: &Self, update: impl FnOnce(&mut dyn ICacheUpdater<T, K>) -> ())
```

Runs an edit that gives the keys (`UpdateFromIntermediate`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L196)

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

### suspend_count

```rust
fn suspend_count(self: &Self) -> Rc<dyn IDisposable>
```

Holds back the notifications of count changes until the result is disposed
(`SuspendCount`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L208)

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

### suspend_notifications

```rust
fn suspend_notifications(self: &Self) -> Rc<dyn IDisposable>
```

Holds back the notifications of changes until the result is disposed; the changes made
meanwhile are delivered as one change set (`SuspendNotifications`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/observable_cache.rs#L216)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`SourceCacheEx<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-sourcecacheex/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Clone`
- [`IConnectableCache<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-iconnectablecache/)
- [`IObservableCache<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-iobservablecache/)
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)
- [`CacheChangeSetSource`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-cachechangesetsource/)

## Availability

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