AbstractNotifyPropertyChanged
struct · ferroui-dynamic-data · v0.5.0
struct AbstractNotifyPropertyChanged
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);
Members
new
fn new() -> Self
A part without handlers.
property_changed
fn property_changed(self: &Self) -> &Event<str>
The event raised when a property value has changed (PropertyChanged).
on_property_changed
fn on_property_changed(self: &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.
set_and_raise
fn set_and_raise<T: PartialEq>(self: &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?)).
set_and_raise_with
fn set_and_raise_with<T>(self: &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?)).
suspend_notifications
fn suspend_notifications(self: &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
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyDefaultDebugINotifyPropertyChanged
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.