pub struct AbstractNotifyPropertyChanged { /* private fields */ }Expand description
The base of an object that notifies the changes of its properties
(AbstractNotifyPropertyChanged).
Deviation (DEVIATIONS.md, DynamicData): upstream’s abstract class is a part that a type embeds;
the type implements INotifyPropertyChanged by returning property_changed,
and its setters call set_and_raise with the property name that
[CallerMemberName] gives upstream (the PascalCase name of the getter, which prop! derives).
use ferroui_dynamic_data::binding::AbstractNotifyPropertyChanged;
use ferroui_system::component_model::INotifyPropertyChanged;
use ferroui_system::events::Event;
use std::cell::Cell;
#[derive(Default)]
struct Item { notify: AbstractNotifyPropertyChanged, age: Cell<i32> }
impl Item {
fn age(&self) -> i32 { self.age.get() }
fn set_age(&self, value: i32) { self.notify.set_and_raise(&self.age, value, "Age") }
}
impl INotifyPropertyChanged for Item {
fn property_changed(&self) -> &Event<str> { self.notify.property_changed() }
}
let item = Item::default();
item.set_age(3);
assert_eq!(item.age(), 3);Implementations§
Source§impl AbstractNotifyPropertyChanged
impl AbstractNotifyPropertyChanged
Sourcepub fn property_changed(&self) -> &Event<str>
pub fn property_changed(&self) -> &Event<str>
The event raised when a property value has changed (PropertyChanged).
Sourcepub fn on_property_changed(&self, property_name: &str)
pub fn on_property_changed(&self, property_name: &str)
Raises PropertyChanged for property_name; an empty name means every property
(OnPropertyChanged(string? propertyName), where null is every property). Nothing is
raised while the notifications are suspended.
Sourcepub fn set_and_raise<T: PartialEq>(
&self,
field: &impl BackingField<T>,
value: T,
property_name: &str,
)
pub fn set_and_raise<T: PartialEq>( &self, field: &impl BackingField<T>, value: T, property_name: &str, )
Assigns value to field and raises PropertyChanged for property_name, unless the
field already holds an equal value (SetAndRaise<T>(ref T, T, string?)).
Sourcepub fn set_and_raise_with<T>(
&self,
field: &impl BackingField<T>,
value: T,
comparer: impl Fn(&T, &T) -> bool,
property_name: &str,
)
pub fn set_and_raise_with<T>( &self, field: &impl BackingField<T>, value: T, comparer: impl Fn(&T, &T) -> bool, property_name: &str, )
set_and_raise with an equality comparer
(SetAndRaise<T>(ref T, T, IEqualityComparer<T>?, string?)).
Sourcepub fn suspend_notifications(
&self,
invoke_property_changed_event_when_finished: bool,
) -> Rc<dyn IDisposable>
pub fn suspend_notifications( &self, invoke_property_changed_event_when_finished: bool, ) -> Rc<dyn IDisposable>
Suspends the notifications until the result is disposed; then, when
invoke_property_changed_event_when_finished is true, raises PropertyChanged for every
property (SuspendNotifications(bool invokePropertyChangeEventWhenDisposed = true)).
Deviation (DEVIATIONS.md, DynamicData): the reference checkout no longer has this member; the earlier API marked it obsolete (“This never worked properly in the first place”). It is ported from that API: the suspension is one flag, so the first disposal of nested suspensions ends it.
Trait Implementations§
Source§impl INotifyPropertyChanged for AbstractNotifyPropertyChanged
impl INotifyPropertyChanged for AbstractNotifyPropertyChanged
Source§fn property_changed(&self) -> &Event<str>
fn property_changed(&self) -> &Event<str>
Source§fn as_notify_property_changing(&self) -> Option<&dyn INotifyPropertyChanging>
fn as_notify_property_changing(&self) -> Option<&dyn INotifyPropertyChanging>
INotifyPropertyChanging, when it also raises the event of a property
that is about to change; None by default. Read more