Skip to main content

LocalProperty

Struct LocalProperty 

Source
pub struct LocalProperty<T> { /* private fields */ }
Expand description

An owner-thread value or computation in Pax’s reactive graph.

Unlike Property, this handle may contain local values and evaluator captures. It cannot cross threads, even when T itself is transferable.

ⓘ
use pax_runtime_api::LocalProperty;
let value = LocalProperty::new(1_u32);
std::thread::spawn(move || value.get());

Implementations§

Source§

impl<T> LocalProperty<T>
where T: PropertyValue,

Source

pub fn local(&self) -> LocalProperty<T>

Clones this owner-thread view without changing its property identity.

Source

pub fn new(val: T) -> LocalProperty<T>

Creates a literal property with an initial value.

Source

pub fn new_from_untyped(untyped: UntypedProperty) -> LocalProperty<T>

Source

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

Creates a computed property from an evaluator and dependency list.

Source

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

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.

Source

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

Creates a named literal property, useful for diagnostics.

Source

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

Creates a named computed property, useful for diagnostics.

Source

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

Creates a named cutoff computed property, useful for diagnostics.

Source

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

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.

Source

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

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.

Source

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 LocalProperty::set can therefore take immediate ownership without the cancelled transition overwriting it on the next runtime tick.

Source

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

Source

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

Source

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.

Source

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

Source

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.

Source

pub fn replace_with(&self, target: LocalProperty<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.

Source

pub fn untyped(&self) -> UntypedProperty

Casts this property to its untyped version.

Trait Implementations§

Source§

impl<T> Clone for LocalProperty<T>
where T: Clone,

Source§

fn clone(&self) -> LocalProperty<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for LocalProperty<T>
where T: PropertyValue + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for LocalProperty<T>
where T: PropertyValue,

Source§

fn default() -> LocalProperty<T>

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for LocalProperty<T>
where T: PropertyValue + Deserialize<'de>,

Source§

fn deserialize<D>( deserializer: D, ) -> Result<LocalProperty<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Interpolatable for LocalProperty<T>
where T: PropertyValue,

Source§

fn interpolate(&self, other: &LocalProperty<T>, t: f64) -> LocalProperty<T>

Interpolates this value toward other at time t on the unit interval. Read more
Source§

impl<T> PropertyBinding<T> for LocalProperty<T>
where T: PropertyValue,

Source§

fn from_value(value: T) -> LocalProperty<T>

Creates independent literal state of this field’s ownership kind.
Source§

fn local(&self) -> LocalProperty<T>

Obtains the owner-thread view used by generated bindings.
Source§

fn from_local(source: LocalProperty<T>) -> LocalProperty<T>

Aliases a local binding, preserving a shared source when one exists.
Source§

impl<T> Serialize for LocalProperty<T>

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> ToPaxValue for LocalProperty<T>

Source§

fn nested_properties(&self) -> Vec<UntypedProperty>

Live properties read when snapshotting a compound value for PAXEL. Adapters observe these as well as the containing property.
Source§

fn to_pax_value(self) -> PaxValue

Converts this value into a PaxValue.
Source§

fn to_pax_value_in_graph(self) -> PaxValue
where Self: Sized,

Converts against owner-thread graph views, including nested generated property fields. Requires an entered property graph for shared fields. Ordinary Self::to_pax_value reads published value snapshots.

Auto Trait Implementations§

§

impl<T> !Send for LocalProperty<T>

§

impl<T> !Sync for LocalProperty<T>

§

impl<T> Freeze for LocalProperty<T>
where PhantomData<T>: Freeze,

§

impl<T> RefUnwindSafe for LocalProperty<T>

§

impl<T> Unpin for LocalProperty<T>
where PhantomData<T>: Unpin,

§

impl<T> UnsafeUnpin for LocalProperty<T>

§

impl<T> UnwindSafe for LocalProperty<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PropertyValue for T
where T: Default + Clone + Interpolatable + 'static,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>