ViewModelBase
struct · ferroui-diagnostics · v0.5.0
struct ViewModelBase
The base of the view models of the developer tools: the property change notification and the helpers that raise it.
A view model embeds it (the base class of the original) and forwards
INotifyPropertyChanged to it. The name of the property is passed
explicitly where the original takes the name of the calling member.
The original also records every addition and removal of a handler in a list that nothing reads; the port leaves that list out.
Members
newset_on_property_changedraise_and_set_if_changedraise_and_set_if_changed_cellraise_property_changed
new
fn new() -> Self
set_on_property_changed
fn set_on_property_changed(self: &Self, handler: Option<Rc<dyn Fn(&str) -> ()>>)
The override of protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
of a deriving view model: called with the name of the property before
the handlers of property_changed.
The base implementation does nothing. A deriving view model sets it
once, when it is constructed (a closure over a weak reference to
itself).
raise_and_set_if_changed
fn raise_and_set_if_changed<T: PartialEq>(self: &Self, field: &RefCell<T>, value: T, property_name: &str) -> bool
RaiseAndSetIfChanged(ref field, value) for a field of a type that is
not Copy: stores value and raises the notification of
property_name when it differs from the stored value. Returns whether
it did.
raise_and_set_if_changed_cell
fn raise_and_set_if_changed_cell<T: PartialEq + Copy>(self: &Self, field: &Cell<T>, value: T, property_name: &str) -> bool
RaiseAndSetIfChanged(ref field, value) for a Copy field.
raise_property_changed
fn raise_property_changed(self: &Self, property_name: &str)
RaisePropertyChanged(propertyName): the override of
OnPropertyChanged, then the handlers.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyClassDefaultsErasedDestructorIntoEitherDefaultINotifyPropertyChanged
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.