pub struct ObservableCache<T, K> { /* private fields */ }Expand description
A cache whose edits and contents can be observed (ObservableCache<TObject, TKey>): the core
of SourceCache, and the cache of AsObservableCache.
Implementations§
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> ObservableCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> ObservableCache<T, K>
Sourcepub fn new(key_selector: impl Fn(&T) -> K + 'static) -> Self
pub fn new(key_selector: impl Fn(&T) -> K + 'static) -> Self
An empty cache whose items are keyed by key_selector
(ObservableCache(Func<TObject, TKey>)).
Sourcepub fn without_key_selector() -> Self
pub fn without_key_selector() -> Self
A cache without a key selector, for edits that give the keys
(ObservableCache(Func<TObject, TKey>? = null)).
Sourcepub fn from_source<C: IChangeSet<T, K>>(source: Rc<dyn IObservable<C>>) -> Self
pub 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>)).
Sourcepub fn key_selector(&self) -> Option<&KeySelector<T, K>>
pub fn key_selector(&self) -> Option<&KeySelector<T, K>>
The key selector of the cache.
Sourcepub fn update_from_source(
&self,
update: impl FnOnce(&mut dyn ISourceUpdater<T, K>),
)
pub fn update_from_source( &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.
Sourcepub fn update_from_intermediate(
&self,
update: impl FnOnce(&mut dyn ICacheUpdater<T, K>),
)
pub fn update_from_intermediate( &self, update: impl FnOnce(&mut dyn ICacheUpdater<T, K>), )
Runs an edit that gives the keys (UpdateFromIntermediate).
Sourcepub fn suspend_count(&self) -> Rc<dyn IDisposable>
pub fn suspend_count(&self) -> Rc<dyn IDisposable>
Holds back the notifications of count changes until the result is disposed
(SuspendCount).
Sourcepub fn suspend_notifications(&self) -> Rc<dyn IDisposable>
pub fn suspend_notifications(&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).
Trait Implementations§
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> CacheChangeSetSource for ObservableCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> CacheChangeSetSource for ObservableCache<T, K>
Source§impl<T, K> Clone for ObservableCache<T, K>
impl<T, K> Clone for ObservableCache<T, K>
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IConnectableCache<T, K> for ObservableCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IConnectableCache<T, K> for ObservableCache<T, K>
Source§fn count_changed(&self) -> Rc<dyn IObservable<usize>>
fn count_changed(&self) -> Rc<dyn IObservable<usize>>
CountChanged).Source§fn connect_with(
&self,
predicate: Option<Rc<dyn Fn(&T) -> bool>>,
suppress_empty_change_sets: bool,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn connect_with( &self, predicate: Option<Rc<dyn Fn(&T) -> bool>>, suppress_empty_change_sets: bool, ) -> Rc<dyn IObservable<ChangeSet<T, K>>>
predicate accepts; empty
change sets are left out unless suppress_empty_change_sets is false (Connect).Source§fn preview_with(
&self,
predicate: Option<Rc<dyn Fn(&T) -> bool>>,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn preview_with( &self, predicate: Option<Rc<dyn Fn(&T) -> bool>>, ) -> Rc<dyn IObservable<ChangeSet<T, K>>>
Preview).Source§fn watch(&self, key: K) -> Rc<dyn IObservable<Change<T, K>>>
fn watch(&self, key: K) -> Rc<dyn IObservable<Change<T, K>>>
key (Watch).Source§fn connect(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn connect(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
Connect()).Source§fn connect_filtered(
&self,
predicate: impl Fn(&T) -> bool + 'static,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>where
Self: Sized,
fn connect_filtered(
&self,
predicate: impl Fn(&T) -> bool + 'static,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>where
Self: Sized,
predicate accepts and their changes (Connect(Func<TObject, bool>)).Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IDisposable for ObservableCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IDisposable for ObservableCache<T, K>
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IObservableCache<T, K> for ObservableCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IObservableCache<T, K> for ObservableCache<T, K>
Source§fn key_values(&self) -> Dictionary<K, T>
fn key_values(&self) -> Dictionary<K, T>
KeyValues).Auto Trait Implementations§
impl<T, K> !RefUnwindSafe for ObservableCache<T, K>
impl<T, K> !Send for ObservableCache<T, K>
impl<T, K> !Sync for ObservableCache<T, K>
impl<T, K> !UnwindSafe for ObservableCache<T, K>
impl<T, K> Freeze for ObservableCache<T, K>
impl<T, K> Unpin for ObservableCache<T, K>
impl<T, K> UnsafeUnpin for ObservableCache<T, K>where
Rc<Inner<T, K>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, K, C> SourceCacheEx<T, K> for C
impl<T, K, C> SourceCacheEx<T, K> for C
Source§fn cast_cache<U: Clone + 'static>(
&self,
converter: impl Fn(&T) -> U + 'static,
) -> Rc<dyn IObservable<ChangeSet<U, K>>>
fn cast_cache<U: Clone + 'static>( &self, converter: impl Fn(&T) -> U + 'static, ) -> Rc<dyn IObservable<ChangeSet<U, K>>>
converter
(Cast(IObservableCache<TSource, TKey>, Func<TSource, TDestination>)).Source§fn add_or_update(&self, item: T)where
Self: ISourceCache<T, K>,
fn add_or_update(&self, item: T)where
Self: ISourceCache<T, K>,
item, or replaces the item of its key (AddOrUpdate(TObject)).Source§fn add_or_update_with_comparer(
&self,
item: T,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
fn add_or_update_with_comparer(
&self,
item: T,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
add_or_update that leaves an equal item, by equality_comparer,
as it is (AddOrUpdate(TObject, IEqualityComparer<TObject>)).Source§fn add_or_update_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
fn add_or_update_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
AddOrUpdate(IEnumerable<TObject>)).Source§fn add_or_update_items_with_comparer(
&self,
items: impl IntoIterator<Item = T>,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
fn add_or_update_items_with_comparer(
&self,
items: impl IntoIterator<Item = T>,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
add_or_update_items that leaves the equal items, by
equality_comparer, as they are (AddOrUpdate(IEnumerable<TObject>, IEqualityComparer<TObject>)).Source§fn clear(&self)where
Self: ISourceCache<T, K>,
fn clear(&self)where
Self: ISourceCache<T, K>,
Clear(ISourceCache)).Source§fn defer_until_loaded(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn defer_until_loaded(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
DeferUntilLoaded(IObservableCache)).Source§fn edit_diff(
&self,
all_items: impl IntoIterator<Item = T>,
are_items_equal: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
fn edit_diff(
&self,
all_items: impl IntoIterator<Item = T>,
are_items_equal: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
all_items with the fewest changes: the items whose keys are gone
are removed, the new keys added, and the items that are_items_equal says differ updated
(EditDiff(IEnumerable<TObject>, Func<TObject, TObject, bool>) and
EditDiff(IEnumerable<TObject>, IEqualityComparer<TObject>)).Source§fn expire_after(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
time_selector gives for it has
passed (None: never), timed on the default scheduler; the removed items with their keys
(ExpireAfter(ISourceCache, Func<TObject, TimeSpan?>, TimeSpan? = null, IScheduler? = null)).Source§fn expire_after_on(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
scheduler: Rc<dyn IScheduler>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after_on( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
expire_after on scheduler.Source§fn expire_after_with_polling(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
polling_interval: Option<Duration>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after_with_polling( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, polling_interval: Option<Duration>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
expire_after that removes the expired items every
polling_interval rather than at their times.Source§fn expire_after_with_polling_on(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
polling_interval: Option<Duration>,
scheduler: Rc<dyn IScheduler>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after_with_polling_on( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, polling_interval: Option<Duration>, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
expire_after_with_polling on scheduler.Source§fn limit_size_to(&self, size_limit: usize) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn limit_size_to(&self, size_limit: usize) -> Rc<dyn IObservable<Vec<(K, T)>>>
size_limit, on the default scheduler; the
removed items with their keys (LimitSizeTo(ISourceCache, int, IScheduler? = null)). Read moreSource§fn limit_size_to_on(
&self,
size_limit: usize,
scheduler: Rc<dyn IScheduler>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn limit_size_to_on( &self, size_limit: usize, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
Source§fn populate_from(
&self,
observable: Rc<dyn IObservable<T>>,
) -> Rc<dyn IDisposable>
fn populate_from( &self, observable: Rc<dyn IObservable<T>>, ) -> Rc<dyn IDisposable>
observable (PopulateFrom(IObservable<TObject>)).Source§fn populate_from_many<I: IntoIterator<Item = T> + 'static>(
&self,
observable: Rc<dyn IObservable<I>>,
) -> Rc<dyn IDisposable>
fn populate_from_many<I: IntoIterator<Item = T> + 'static>( &self, observable: Rc<dyn IObservable<I>>, ) -> Rc<dyn IDisposable>
observable
(PopulateFrom(IObservable<IEnumerable<TObject>>)).Source§fn refresh(&self, item: &T)where
Self: ISourceCache<T, K>,
fn refresh(&self, item: &T)where
Self: ISourceCache<T, K>,
item has changed (Refresh(TObject)).Source§fn refresh_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
fn refresh_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
Refresh(IEnumerable<TObject>)).Source§fn refresh_all(&self)where
Self: ISourceCache<T, K>,
fn refresh_all(&self)where
Self: ISourceCache<T, K>,
Refresh()).Source§fn remove(&self, item: &T)where
Self: ISourceCache<T, K>,
fn remove(&self, item: &T)where
Self: ISourceCache<T, K>,
item (Remove(TObject)).Source§fn remove_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
fn remove_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
items (Remove(IEnumerable<TObject>)).Source§fn remove_key(&self, key: K)where
Self: ISourceCache<T, K>,
fn remove_key(&self, key: K)where
Self: ISourceCache<T, K>,
key (RemoveKey(TKey), and Remove(TKey)).Source§fn remove_keys(&self, keys: impl IntoIterator<Item = K>)where
Self: ISourceCache<T, K>,
fn remove_keys(&self, keys: impl IntoIterator<Item = K>)where
Self: ISourceCache<T, K>,
keys (RemoveKeys(IEnumerable<TKey>), and
Remove(IEnumerable<TKey>)).Source§fn watch_value(&self, key: K) -> Rc<dyn IObservable<T>>
fn watch_value(&self, key: K) -> Rc<dyn IObservable<T>>
key each time it changes (WatchValue(IObservableCache, TKey)).