Type Alias BoolAttribute

pub type BoolAttribute = MaybeDyn<bool>;
Expand description

Type alias respresenting a possibly dynamic boolean value.

Aliased Type§

enum BoolAttribute {
    Static(bool),
    Signal(ReadSignal<bool>),
    Derived(Rc<dyn Fn() -> MaybeDyn<bool>>),
}

Variants§

§

Static(bool)

A static value.

§

Signal(ReadSignal<bool>)

A dynamic value backed by a signal.

§

Derived(Rc<dyn Fn() -> MaybeDyn<bool>>)

A derived dynamic value.

Implementations

§

impl<T> MaybeDyn<T>
where T: Into<MaybeDyn<T>> + 'static,

pub fn evaluate(self) -> T
where T: Clone,

Get the value by consuming itself. Unlike get_clone, this method avoids a clone if we are just storing a static value.

pub fn get(&self) -> T
where T: Copy,

Get the value by copying it.

If the type does not implement Copy, consider using get_clone instead.

pub fn get_clone(&self) -> T
where T: Clone,

Get the value by cloning it.

If the type implements Copy, consider using get instead.

pub fn track(&self)

Track the reactive dependencies, if it is dynamic.

pub fn as_static(&self) -> Option<&T>

Tries to get the value statically or returns None if value is dynamic.

Trait Implementations

§

impl AttributeValue for MaybeDyn<bool>

§

fn set_self(self, el: &mut SsrNode, name: Cow<'static, str>)

§

impl<T> Clone for MaybeDyn<T>
where T: Clone + Into<MaybeDyn<T>> + 'static,

§

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

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

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

Performs copy-assignment from source. Read more
§

impl<F, U, T> From<F> for MaybeDyn<T>
where T: Into<MaybeDyn<T>>, F: Fn() -> U + 'static, U: Into<MaybeDyn<T>>,

§

fn from(f: F) -> MaybeDyn<T>

Converts to this type from the input type.
§

impl<T, U> From<ReadSignal<U>> for MaybeDyn<T>
where T: Into<MaybeDyn<T>>, U: Into<MaybeDyn<T>> + Clone,

§

fn from(val: ReadSignal<U>) -> MaybeDyn<T>

Converts to this type from the input type.
§

impl<T, U> From<Signal<U>> for MaybeDyn<T>
where T: Into<MaybeDyn<T>>, U: Into<MaybeDyn<T>> + Clone,

§

fn from(val: Signal<U>) -> MaybeDyn<T>

Converts to this type from the input type.
§

impl From<bool> for MaybeDyn<bool>

§

fn from(val: bool) -> MaybeDyn<bool>

Converts to this type from the input type.