leptos::tachys::reactive_graph::bind

Struct Bind

Source
pub struct Bind<Key, T, R, W>
where Key: AttributeKey, T: FromEventTarget + AttributeValue + 'static, R: Get<Value = T> + Clone + 'static, W: Update<Value = T>,
{ /* private fields */ }
Expand description

Two-way binding of an attribute and an event listener

Implementations§

Source§

impl<Key, T, R, W> Bind<Key, T, R, W>
where Key: AttributeKey, T: FromEventTarget + AttributeValue + PartialEq + Sync + 'static, R: Get<Value = T> + Clone + Send + Sync + 'static, W: Update<Value = T> + Clone + 'static, Element: ChangeEvent + GetValue<T>,

Source

pub fn attach(self, el: &Element) -> RemoveEventHandler<Element>

Attaches the event listener that updates the signal value to the element.

Source

pub fn read_signal(&self, el: &Element) -> Signal<BoolOrT<T>>

Creates the signal to update the value of the attribute. This signal is different when using a "group" attribute

Source

pub fn key(&self) -> &'static str

Returns the key of the attribute. If the key is "group" it returns "checked", otherwise the one which was provided originally.

Trait Implementations§

Source§

impl<Key, T, R, W> Attribute for Bind<Key, T, R, W>
where Key: AttributeKey, T: FromEventTarget + AttributeValue + PartialEq + Sync + 'static, R: Get<Value = T> + Clone + Send + Sync + 'static, Signal<BoolOrT<T>>: IntoProperty, W: Update<Value = T> + Clone + Send + 'static, Element: ChangeEvent + GetValue<T>,

Source§

const MIN_LENGTH: usize = 0usize

The minimum length of this attribute in HTML.
Source§

type State = (<Signal<BoolOrT<T>> as IntoProperty>::State, (Element, Option<RemoveEventHandler<Element>>))

The state that should be retained between building and rebuilding.
Source§

type AsyncOutput = Bind<Key, T, R, W>

The type once all async data have loaded.
Source§

type Cloneable = Bind<Key, T, R, W>

An equivalent to this attribute that can be cloned to be shared across elements.
Source§

type CloneableOwned = Bind<Key, T, R, W>

An equivalent to this attribute that can be cloned to be shared across elements, and captures no references shorter than 'static.
Source§

fn html_len(&self) -> usize

An approximation of the actual length of this attribute in HTML.
Source§

fn to_html( self, _buf: &mut String, _class: &mut String, _style: &mut String, _inner_html: &mut String, )

Renders the attribute to HTML. Read more
Source§

fn hydrate<const FROM_SERVER: bool>( self, el: &Element, ) -> <Bind<Key, T, R, W> as Attribute>::State

Adds interactivity as necessary, given DOM nodes that were created from HTML that has either been rendered on the server, or cloned for a <template>.
Source§

fn build(self, el: &Element) -> <Bind<Key, T, R, W> as Attribute>::State

Adds this attribute to the element during client-side rendering.
Source§

fn rebuild(self, state: &mut <Bind<Key, T, R, W> as Attribute>::State)

Applies a new value for the attribute.
Source§

fn into_cloneable(self) -> <Bind<Key, T, R, W> as Attribute>::Cloneable

Converts this attribute into an equivalent that can be cloned.
Source§

fn into_cloneable_owned( self, ) -> <Bind<Key, T, R, W> as Attribute>::CloneableOwned

Converts this attributes into an equivalent that can be cloned and is 'static.
Source§

fn dry_resolve(&mut self)

“Runs” the attribute without other side effects. For primitive types, this is a no-op. For reactive types, this can be used to gather data about reactivity or about asynchronous data that needs to be loaded.
Source§

async fn resolve(self) -> <Bind<Key, T, R, W> as Attribute>::AsyncOutput

“Resolves” this into a type that is not waiting for any asynchronous data.
Source§

impl<Key, T, R, W> Clone for Bind<Key, T, R, W>
where Key: AttributeKey, T: FromEventTarget + AttributeValue + 'static, R: Get<Value = T> + Clone + 'static, W: Update<Value = T> + Clone,

Source§

fn clone(&self) -> Bind<Key, T, R, W>

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
Source§

impl<Key, T, R, W> Debug for Bind<Key, T, R, W>
where Key: Debug + AttributeKey, T: Debug + FromEventTarget + AttributeValue + 'static, R: Debug + Get<Value = T> + Clone + 'static, W: Debug + Update<Value = T>,

Source§

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

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

impl<Key, T, R, W> NextAttribute for Bind<Key, T, R, W>
where Key: AttributeKey, T: FromEventTarget + AttributeValue + PartialEq + Sync + 'static, R: Get<Value = T> + Clone + Send + Sync + 'static, Signal<BoolOrT<T>>: IntoProperty, W: Update<Value = T> + Clone + Send + 'static, Element: ChangeEvent + GetValue<T>,

Source§

type Output<NewAttr: Attribute> = (Bind<Key, T, R, W>, NewAttr)

The type of the new, combined attribute.
Source§

fn add_any_attr<NewAttr>( self, new_attr: NewAttr, ) -> <Bind<Key, T, R, W> as NextAttribute>::Output<NewAttr>
where NewAttr: Attribute,

Adds a new attribute.
Source§

impl<Key, T, R, W> ToTemplate for Bind<Key, T, R, W>
where Key: AttributeKey, T: FromEventTarget + AttributeValue + 'static, R: Get<Value = T> + Clone + 'static, W: Update<Value = T> + Clone,

Source§

fn to_template( _buf: &mut String, _class: &mut String, _style: &mut String, _inner_html: &mut String, _position: &mut Position, )

Renders a view type to a template. This does not take actual view data, but can be used for constructing part of an HTML <template> that corresponds to a view of a particular type.
Source§

const TEMPLATE: &'static str = ""

The HTML content of the static template.
Source§

const CLASS: &'static str = ""

The class attribute content known at compile time.
Source§

const STYLE: &'static str = ""

The style attribute content known at compile time.
Source§

const LEN: usize = _

The length of the template.

Auto Trait Implementations§

§

impl<Key, T, R, W> Freeze for Bind<Key, T, R, W>
where Key: Freeze, R: Freeze, W: Freeze,

§

impl<Key, T, R, W> RefUnwindSafe for Bind<Key, T, R, W>

§

impl<Key, T, R, W> Send for Bind<Key, T, R, W>
where R: Send, W: Send,

§

impl<Key, T, R, W> Sync for Bind<Key, T, R, W>
where Key: Sync, R: Sync, W: Sync,

§

impl<Key, T, R, W> Unpin for Bind<Key, T, R, W>
where Key: Unpin, R: Unpin, W: Unpin,

§

impl<Key, T, R, W> UnwindSafe for Bind<Key, T, R, W>
where Key: UnwindSafe, R: UnwindSafe, W: UnwindSafe,

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoAnyAttribute for T
where T: Send + Attribute + 'static, <T as Attribute>::State: 'static, Element: Clone,

Source§

fn into_any_attr(self) -> AnyAttribute

Wraps the given attribute.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T