Computed

Struct Computed 

Source
pub struct Computed<T>(/* private fields */);
Expand description

A wrapper around a boxed implementation of the ComputedImpl trait.

This type represents a computation that can be evaluated to produce a result of type T. The computation is stored as a boxed trait object, allowing for dynamic dispatch.

Implementations§

Source§

impl<T> Computed<T>

Source

pub fn new<C>(value: C) -> Computed<T>
where C: Signal<Output = T> + Clone + 'static,

Creates a new Computed<T> from a value that implements Compute<Output = T>.

The provided value is boxed and stored internally.

Source§

impl<T> Computed<T>
where T: 'static + Clone,

Source

pub fn constant(value: T) -> Computed<T>

Creates a new constant computation with the provided value.

This is a convenience wrapper around Computed::new(constant(value)).

Trait Implementations§

Source§

impl<T, C2> Add<C2> for Computed<T>
where C2: Signal, T: Add<<C2 as Signal>::Output> + Clone + 'static, <C2 as Signal>::Output: Clone,

Source§

type Output = Map<Zip<Computed<T>, C2>, fn((T, <C2 as Signal>::Output)) -> <T as Add<<C2 as Signal>::Output>>::Output, <T as Add<<C2 as Signal>::Output>>::Output>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: C2) -> <Computed<T> as Add<C2>>::Output

Performs the + operation. Read more
Source§

impl<T> Clone for Computed<T>
where T: 'static,

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Computed<T>

Implements Debug for Computed<T>.

This just outputs the type name rather than any internal details.

Source§

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

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

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

Implements Default for Computed<T> when T implements Default.

This creates a constant computation with the default value of T.

Source§

fn default() -> Computed<T>

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

impl<T> From<Binding<T>> for Computed<T>

Source§

fn from(val: Binding<T>) -> Computed<T>

Converts to this type from the input type.
Source§

impl<T> Signal for Computed<T>
where T: 'static,

Implements Compute for Computed<T>.

This delegates to the internal boxed implementation.

Source§

type Output = T

The type of value produced by this computation.
Source§

type Guard = Box<dyn WatcherGuard>

The guard type returned by the watch method that manages watcher lifecycle.
Source§

fn get(&self) -> <Computed<T> as Signal>::Output

Execute the computation and return the current value.
Source§

fn watch( &self, watcher: impl Fn(Context<<Computed<T> as Signal>::Output>) + 'static, ) -> <Computed<T> as Signal>::Guard

Register a watcher to be notified when the computed value changes. Read more
Source§

impl<V: View> View for Computed<V>
where Self: 'static,

Source§

fn body(self, _env: &Environment) -> impl View

Build this view and return the content. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Computed<T>

§

impl<T> !RefUnwindSafe for Computed<T>

§

impl<T> !Send for Computed<T>

§

impl<T> !Sync for Computed<T>

§

impl<T> Unpin for Computed<T>

§

impl<T> !UnwindSafe for Computed<T>

Blanket Implementations§

Source§

impl<S> AnimationExt for S
where S: SignalExt,

Source§

fn animated(self) -> WithMetadata<Self, Animation>
where Self: Sized,

Apply default animation to this reactive value Read more
Source§

fn with_animation(self, animation: Animation) -> WithMetadata<Self, Animation>
where Self: Sized,

Apply a specific animation to this reactive value Read more
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<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<C, F, T1, T2, Output> FlattenMap<F, (T1, T2), Output> for C
where C: Signal<Output = (T1, T2)> + 'static, F: 'static + Clone + Fn(T1, T2) -> Output, T1: 'static, T2: 'static, Output: 'static,

Source§

fn flatten_map(self, f: F) -> Map<C, impl Clone + Fn((T1, T2)), Output>

Maps a function over the flattened elements of a nested tuple. Read more
Source§

impl<C, F, T1, T2, T3, Output> FlattenMap<F, (T1, T2, T3), Output> for C
where C: Signal<Output = ((T1, T2), T3)> + 'static, F: 'static + Clone + Fn(T1, T2, T3) -> Output, Output: 'static,

Source§

fn flatten_map(self, f: F) -> Map<C, impl Clone + Fn(((T1, T2), T3)), Output>

Maps a function over the flattened elements of a nested tuple. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
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<V> IntoView for V
where V: View,

Source§

type Output = V

The resulting View type after conversion.
Source§

fn into_view(self, _env: &Environment) -> <V as IntoView>::Output

Converts the implementing type into a View. Read more
Source§

impl<C> SignalExt for C
where C: Signal,

Source§

fn map<F, Output>(self, f: F) -> Map<Self, F, Output>
where F: 'static + Clone + Fn(Self::Output) -> Output, Output: 'static, Self: 'static,

Transforms the output of this signal using the provided function.
Source§

fn zip<B>(self, b: B) -> Zip<Self, B>
where B: Signal, Self::Output: Clone, <B as Signal>::Output: Clone,

Combines this signal with another signal into a tuple.
Source§

fn cached(self) -> Cached<Self>
where Self::Output: Clone,

Wraps this signal with caching to avoid redundant computations.
Source§

fn computed(self) -> Computed<Self::Output>
where Self: 'static,

Converts this signal into a type-erased Computed container.
Source§

fn with<T>(self, metadata: T) -> WithMetadata<Self, T>

Attaches metadata to this signal’s watcher notifications.
Source§

fn debounce(self, duration: Duration) -> Debounce<Self, DefaultExecutor>
where Self::Output: Clone,

Creates a debounced version of this signal. Read more
Source§

fn throttle(self, duration: Duration) -> Throttle<Self, DefaultExecutor>
where Self::Output: Clone,

Creates a throttled version of this signal. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.