Skip to main content

Prop

Struct Prop 

Source
pub struct Prop<T: 'static> { /* private fields */ }
Expand description

A prop of a component that runs once (a field of its #[derive(Props)] struct): read it in a binding, props.max.get(), and the binding runs again when it changes. Copy, like a signal: closures capture it as it is.

A Rust parent passes a value, a signal, a memo or a closure (.into(), Prop::bind); JS passes values, one prop at a time. In the component’s instance each prop is a signal of its own, so a new value from JS (or a parent’s binding) reaches only what read it.

Implementations§

Source§

impl<T: Clone + PartialEq + 'static> Prop<T>

Source

pub fn new(value: T) -> Self

A prop given value (a signal of the current owner).

Source

pub fn bind(f: impl Fn() -> T + 'static) -> Self

A prop bound to f (a memo of the current owner): run again when what it reads changes.

Source

pub fn get(&self) -> T

The value, subscribing the running computation.

Source

pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R

f of the value, subscribing the running computation.

Source

pub fn get_untracked(&self) -> T

The value, without subscribing.

Source

pub fn with_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> R

f of the value, without subscribing.

Source§

impl Prop<Option<Slot>>

Source

pub fn place( self, style: impl Fn(SlotElement) -> SlotElement + 'static, ) -> AnyElement

The slot where the app fills it, styled by style: it comes and goes as the app fills and empties it.

Trait Implementations§

Source§

impl<T> Clone for Prop<T>

Source§

fn clone(&self) -> Self

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> Copy for Prop<T>

Source§

impl<T> Debug for Prop<T>

Source§

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

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

impl<T: Clone + PartialEq + Default + 'static> Default for Prop<T>

Source§

fn default() -> Self

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

impl From<&'static str> for Prop<SharedString>

Source§

fn from(value: &'static str) -> Self

Converts to this type from the input type.
Source§

impl From<&'static str> for Prop<Option<SharedString>>

An optional text given as text (label: "Name".into()).

Source§

fn from(value: &'static str) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + PartialEq + 'static> From<Memo<T>> for Prop<T>

Source§

fn from(value: Memo<T>) -> Self

Converts to this type from the input type.
Source§

impl From<Prop<Children>> for Children

The app’s children, to wrap one by one (.children_each(props.children, ..)).

Source§

fn from(children: Prop<Children>) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + PartialEq + 'static> From<Reactive<T>> for Prop<T>

Source§

fn from(value: Reactive<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + PartialEq + 'static> From<ReadSignal<T>> for Prop<T>

Source§

fn from(value: ReadSignal<T>) -> Self

Converts to this type from the input type.
Source§

impl From<SharedString> for Prop<Option<SharedString>>

Source§

fn from(value: SharedString) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + PartialEq + 'static> From<Signal<T>> for Prop<T>

Source§

fn from(value: Signal<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Prop<SharedString>

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Prop<Option<SharedString>>

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + PartialEq + 'static> From<T> for Prop<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Prop<Option<bool>>

An optional flag given as a flag (.cover(false)): set, where left out is a default of the component’s own.

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl IntoElement for Prop<Children>

The app’s children placed here, all at one place (.child(props.children)).

Source§

fn into_element(self) -> AnyElement

As an element.
Source§

impl<T: Clone + PartialEq + 'static> IntoReactive<T> for Prop<T>

A prop passed on, to an element’s setter or a child’s prop: bound to it (text(props.title)).

Source§

impl<T> PartialEq for Prop<T>

The same node.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<T> Forget for Prop<T>

§

impl<T> Freeze for Prop<T>
where PhantomData<fn() -> T>: Freeze,

§

impl<T> Move for Prop<T>

§

impl<T> RefUnwindSafe for Prop<T>

§

impl<T> Send for Prop<T>

§

impl<T> Sync for Prop<T>

§

impl<T> Unpin for Prop<T>

§

impl<T> UnsafeUnpin for Prop<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Prop<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<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> 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> IntoElements for T
where T: IntoElement,

Source§

fn into_elements(self) -> Vec<AnyElement>

As elements.
Source§

impl<T> IntoUniform for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.