Struct pax_runtime_api::properties::Property
source · pub struct Property<T> { /* private fields */ }
Expand description
A typed wrapper over a UntypedProperty that casts to/from an untyped property on get/set
Implementations§
source§impl<T: PropertyValue> Property<T>
impl<T: PropertyValue> Property<T>
pub fn new(val: T) -> Self
pub fn computed( evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty] ) -> Self
pub fn new_with_name(val: T, name: &str) -> Self
pub fn computed_with_name( evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty], name: &str ) -> Self
pub fn ease_to(&self, end_val: T, time: u64, curve: EasingCurve)
pub fn ease_to_later(&self, end_val: T, time: u64, curve: EasingCurve)
sourcepub fn get(&self) -> T
pub fn get(&self) -> T
Gets the currently stored value. Might be computationally expensive in a large reactivity network since this triggers re-evaluation of dirty property chains
sourcepub fn set(&self, val: T)
pub fn set(&self, val: T)
Sets this properties value and sets the drity bit recursively of all of it’s dependencies if not already set
pub fn update(&self, f: impl FnOnce(&mut T))
pub fn read<V>(&self, f: impl FnOnce(&T) -> V) -> V
sourcepub fn replace_with(&self, target: Property<T>)
pub fn replace_with(&self, target: Property<T>)
replaces a properties evaluation/inbounds/value to be the same as target, while keeping it’s dependents. WARNING: this method can introduce circular dependencies if one is not careful. Using it wrongly can introduce memory leaks and inconsistent property behaviour. This method can be used to replace an inner value from for example a literal to a computed computed, while keeping the link to it’s dependents
sourcepub fn untyped(&self) -> UntypedProperty
pub fn untyped(&self) -> UntypedProperty
Casts this property to it’s untyped version
Trait Implementations§
source§impl<T: PropertyValue> Default for Property<T>
impl<T: PropertyValue> Default for Property<T>
source§impl<'de, T: PropertyValue + Deserialize<'de>> Deserialize<'de> for Property<T>
impl<'de, T: PropertyValue + Deserialize<'de>> Deserialize<'de> for Property<T>
Serialization and deserialization fully disconnects properties, and only loads them back in as literals.