properties

Structs

Property

A reactive value node in Pax's property graph.

Property<T> is the primary state and binding primitive used by generated components, PAXEL expressions, and Rust component logic.

Implementations

cancel_transitions
pub fn cancel_transitions(&self)

Stops the active transition and clears every queued transition segment.

The property is left at its current eased value. A subsequent [Property::set] can therefore take immediate ownership without the cancelled transition overwriting it on the next runtime tick.

computed
pub fn computed(evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty]) -> Self

Creates a computed property from an evaluator and dependency list.

computed_with_cutoff
pub fn computed_with_cutoff(evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty], cutoff: impl Fn(&T, &T) -> bool + 'static) -> Self

Creates a computed property with a propagation cutoff.

The predicate receives the last accepted value and the newly evaluated candidate. Returning true discards the candidate and stops outbound invalidation at this property; returning false accepts and propagates it. The first evaluation is always accepted.

computed_with_cutoff_and_name
pub fn computed_with_cutoff_and_name(evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty], cutoff: impl Fn(&T, &T) -> bool + 'static, name: &str) -> Self

Creates a named cutoff computed property, useful for diagnostics.

computed_with_name
pub fn computed_with_name(evaluator: impl Fn() -> T + 'static, dependents: &[UntypedProperty], name: &str) -> Self

Creates a named computed property, useful for diagnostics.

ease_to
pub fn ease_to<D: Into<Duration>>(&self, end_val: T, duration: D, curve: EasingCurve)

Immediately starts an ease transition from the current value to end_val, over a duration, following curve.

Numeric arguments preserve the historical frame-based behavior. Use Duration::Milliseconds, Duration::Seconds, or Duration::Frames to select an explicit unit.

ease_to_later
pub fn ease_to_later<D: Into<Duration>>(&self, end_val: T, duration: D, curve: EasingCurve)

Enqueues an ease transition from the current value to end_val, over a duration, following curve, which will start after all currently enqueued transitions finish.

get
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

new
pub fn new(val: T) -> Self

Creates a literal property with an initial value.

new_with_name
pub fn new_with_name(val: T, name: &str) -> Self

Creates a named literal property, useful for diagnostics.

read
pub fn read<V>(&self, f: impl FnOnce(&T) -> V) -> V

Reads the inner value by reference.

Panics if this property is already borrowed, which can happen if read is called inside a read of the same property.

replace_with
pub fn replace_with(&self, target: Property<T>)

Replaces this property's evaluator, dependencies, and value with target, while keeping dependents.

This can introduce circular dependencies if used carelessly. It is intended for changing a property from literal to computed (or vice versa) without severing existing outbound links.

set
pub fn set(&self, val: T)

Sets this properties value and sets the dirty bit recursively of all of its dependencies if not already set

set_if_neq
pub fn set_if_neq(&self, val: T) -> bool where T: PartialEq

Sets the value only when it differs from the current one.

Returns true when the write changed the property and dirtied dependents.

untyped
pub fn untyped(&self) -> UntypedProperty

Casts this property to its untyped version.

update
pub fn update(&self, f: impl FnOnce(&mut T))

Get access to a mutable reference to the inner value T. Will trigger updates for dependents of this property, regardless of if the value actually changed

Traits

PropertyValue

Bound for values that can live inside Pax Property<T>.

Values must be cloneable for .get(), interpolatable for transitions, and 'static because properties are stored in the runtime graph.