ObservableCollectionExtended
struct · ferroui-dynamic-data · v0.5.0
struct ObservableCollectionExtended<T>
An observable collection with ranges, loads and suspended notifications
(ObservableCollectionExtended<T>), the collection that the binding operators fill.
It is a shared handle over an ObservableCollection<T> (the base class upstream), which items
controls read and observe: collection is that collection. The changes made
through this handle raise the notifications of the base, except those that are suspended
(upstream's overrides of OnCollectionChanged and OnPropertyChanged).
Deviation (DEVIATIONS.md, DynamicData): a subclass of .NET intercepts the notifications of every
change; here the changes made through collection directly are not
suspended.
Members
newwith_capacityfrom_itemscollectionptr_eqadd_collection_changedremove_collection_changedcountis_emptygetitemsto_veccontainsindex_ofaddinsertsetremove_atremovemove_itemclearadd_rangeinsert_rangeloadremove_rangesuspend_countsuspend_notificationson_property_changedon_collection_changed
new
fn new() -> Self
An empty collection (ObservableCollectionExtended()).
with_capacity
fn with_capacity(capacity: usize) -> Self
An empty collection that has room for capacity items (ObservableCollectionExtended(new List<T>(capacity))).
from_items
fn from_items(items: Vec<T>) -> Self
A collection of the items (ObservableCollectionExtended(IEnumerable<T>),
ObservableCollectionExtended(List<T>)).
collection
fn collection(self: &Self) -> &ObservableCollection<T>
The observable collection of the items (the base class upstream).
ptr_eq
fn ptr_eq(self: &Self, other: &Self) -> bool
Whether self and other are the same collection.
add_collection_changed
fn add_collection_changed(self: &Self, handler: Rc<CollectionChangedHandler<T>>) -> u64
Adds a handler of the typed change notifications; returns the token that removes it
(CollectionChanged +=).
remove_collection_changed
fn remove_collection_changed(self: &Self, token: u64) -> bool
Removes a handler (CollectionChanged -=).
count
fn count(self: &Self) -> usize
The number of items (Count).
is_empty
fn is_empty(self: &Self) -> bool
get
fn get(self: &Self, index: usize) -> T
The item at index (the indexer's getter).
items
fn items(self: &Self) -> Ref<'_, Vec<T>>
The items, borrowed.
to_vec
fn to_vec(self: &Self) -> Vec<T>
A copy of the items.
contains
fn contains(self: &Self, item: &T) -> bool
Whether the collection has item (Contains).
index_of
fn index_of(self: &Self, item: &T) -> Option<usize>
The index of item (IndexOf).
add
fn add(self: &Self, item: T)
Adds an item at the end (Add).
insert
fn insert(self: &Self, index: usize, item: T)
Inserts an item (InsertItem).
set
fn set(self: &Self, index: usize, item: T)
Replaces the item at index (the indexer's setter, SetItem).
remove_at
fn remove_at(self: &Self, index: usize)
Removes the item at index (RemoveItem).
remove
fn remove(self: &Self, item: &T) -> bool
Removes item; false when it is not there (Remove).
move_item
fn move_item(self: &Self, old_index: usize, new_index: usize)
Moves the item at old_index to new_index (Move, MoveItem).
clear
fn clear(self: &Self)
Removes every item (ClearItems): a reset.
add_range
fn add_range(self: &Self, items: impl IntoIterator<Item = T>)
Adds the items at the end, one at a time (AddRange).
insert_range
fn insert_range(self: &Self, items: impl IntoIterator<Item = T>, index: usize)
Inserts the items from index, one at a time (InsertRange).
load
fn load(self: &Self, items: impl IntoIterator<Item = T>)
Clears the collection and adds the items (Load).
remove_range
fn remove_range(self: &Self, index: usize, count: usize)
Removes count items from index, one at a time (RemoveRange).
suspend_count
fn suspend_count(self: &Self) -> Rc<dyn IDisposable>
Holds back the notifications of Count until the handle is disposed, which raises Count
once if it changed (SuspendCount).
suspend_notifications
fn suspend_notifications(self: &Self) -> Rc<dyn IDisposable>
Holds back the notifications of changes and of Count until the handle is disposed, which
raises Count and a reset (SuspendNotifications).
on_property_changed
fn on_property_changed(self: &Self, name: &str)
Raises PropertyChanged, unless it is Count and the count is suspended
(OnPropertyChanged).
on_collection_changed
fn on_collection_changed(self: &Self, action: NotifyCollectionChangedAction, new_items: &[T], old_items: &[T], new_starting_index: i32, old_starting_index: i32)
Raises CollectionChanged, unless the notifications are suspended (OnCollectionChanged).
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedObservableCollectionEx<T>ClonePartialEqDefaultDebugINotifyCollectionChangedINotifyPropertyChangedINotifyCollectionChangedSuspenderIObservableCollection<T>IList<T>IExtendedList<T>From<&ObservableCollectionExtended<T>>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.