Function maple_core::flow::Keyed[][src]

pub fn Keyed<T, F: 'static, K: 'static, Key: 'static>(
    props: KeyedProps<T, F, K, Key>
) -> TemplateResult where
    F: Fn(T) -> TemplateResult,
    K: Fn(&T) -> Key,
    Key: Clone + Hash + Eq,
    T: Clone + PartialEq

Keyed iteration. Use this instead of directly rendering an array of TemplateResults. Using this will minimize re-renders instead of re-rendering every single node on every state change.

For non keyed iteration, see Indexed.

Example

use maple_core::prelude::*;

let count = Signal::new(vec![1, 2]);

let node = template! {
    Keyed(KeyedProps {
        iterable: count.handle(),
        template: |item| template! {
            li { (item) }
        },
        key: |item| *item,
    })
};