pub struct ListProps<TitemsSignal: SignalVec<Item = Dom> = Always<Dom>, TApplyFn: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement> = fn(_: DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement>> {
    pub items: Option<TitemsSignal>,
    pub apply: Option<TApplyFn>,
}
Expand description

Renders a list of items.

Examples

use dominator::html;
use futures_signals::signal_vec::{MutableVec, SignalVecExt};
use dmat_components::components::list;
use dmat_components::list;
use dmat_components::components::list::*;

// Static list, items never change
let my_static_list = list!({.rows([
    html!("span", {.text("Hello")}),
    html!("span", {.text("World")}),
])});

// Dynamic list, items change according to the content of the mutable vector
let my_items = MutableVec::new_with_values(vec!["Hello", "World"]);
let my_dynamic_list = list!({
    .rows_signal_vec(my_items.signal_vec_cloned()
        .map(|item| html!("span", { .text(item) })))
});

Fields§

§items: Option<TitemsSignal>§apply: Option<TApplyFn>

Implementations§

source§

impl ListProps

source

pub fn new() -> Self

source§

impl<TitemsSignal: SignalVec<Item = Dom>, TApplyFn: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement>> ListProps<TitemsSignal, TApplyFn>

source

pub fn items(self, v: impl Into<Vec<Dom>>) -> ListProps<Always<Dom>, TApplyFn>

The list of items to render. Each item is wrapped in a <li> element by the list component.

source

pub fn items_signal_vec<TitemsSignalNew: SignalVec<Item = Dom>>( self, v: TitemsSignalNew ) -> ListProps<TitemsSignalNew, TApplyFn>

The list of items to render. Each item is wrapped in a <li> element by the list component.

source§

impl<TitemsSignal: SignalVec<Item = Dom>, TApplyFn: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement>> ListProps<TitemsSignal, TApplyFn>

source

pub fn apply<TApplyFnNew: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement>>( self, v: TApplyFnNew ) -> ListProps<TitemsSignal, TApplyFnNew>

Trait Implementations§

source§

impl<TitemsSignal: SignalVec<Item = Dom>, TApplyFn: FnOnce(DomBuilder<HtmlElement>) -> DomBuilder<HtmlElement>> ListPropsTrait for ListProps<TitemsSignal, TApplyFn>

§

type TitemsSignal = TitemsSignal

§

type TApplyFn = TApplyFn

source§

fn take(self) -> ListProps<TitemsSignal, TApplyFn>

Auto Trait Implementations§

§

impl<TitemsSignal, TApplyFn> RefUnwindSafe for ListProps<TitemsSignal, TApplyFn>where TApplyFn: RefUnwindSafe, TitemsSignal: RefUnwindSafe,

§

impl<TitemsSignal, TApplyFn> Send for ListProps<TitemsSignal, TApplyFn>where TApplyFn: Send, TitemsSignal: Send,

§

impl<TitemsSignal, TApplyFn> Sync for ListProps<TitemsSignal, TApplyFn>where TApplyFn: Sync, TitemsSignal: Sync,

§

impl<TitemsSignal, TApplyFn> Unpin for ListProps<TitemsSignal, TApplyFn>where TApplyFn: Unpin, TitemsSignal: Unpin,

§

impl<TitemsSignal, TApplyFn> UnwindSafe for ListProps<TitemsSignal, TApplyFn>where TApplyFn: UnwindSafe, TitemsSignal: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.