pub fn view<F, U, V>(&self, enclose: crate::Tag<U>, object: F) -> crate::Tag<U>
    where
        F: FnOnce(T) -> V,
        F: Clone + 'static,
        V: component::Component + 'static,
        U: html::elements::HtmlElement,
    {
        for i in self.value.read().iter() {
            enclose.node.push_child(object.clone()(i.clone()).into())
        }

        let node = enclose.node.clone();
        let (tx, rx) = unbuffered_channel();
        self.tx.write().push(tx);
        wasm_bindgen_futures::spawn_local(async move {
            while let Some(change) = rx.receive().await {
                match change {
                    Change::Insert(i, x) => node.insert_child(i, object.clone()(x).into()),
                    Change::Push(x) => node.push_child(object.clone()(x).into()),
                    Change::Remove(i) => node.remove_child(i),
                    Change::Pop => node.pop_child(),
                }
            }
        });

        enclose
    }
/// Render the StateVec to the DOM.
/// It will update if any element changes or even if the list changes automatically.
///
///  - `enclose` is the `Component` inside which all of the elements will be present.
///  - `object` is the function which will return a `Component` when passed a type following
/// the `StateTrait`. The function will define how all the elements will be seen inside
/// the `enclose`.
///
/// # Examples
///
/// ```
/// # use valerie::prelude::*;
/// # use valerie::prelude::components::*;
/// # use wasm_bindgen_test::*;
/// # fn ui() -> Node {
/// let vec = StateVec::with_capacity(10);
/// (0..10).for_each(|x| vec.push(StateAtomic::new(x)));
///
/// div!(
///     vec.view(ul!(), |x| li!(x)),
///     br!(),
///     vec.view(ol!(), |x| li!("Element ", x))
/// )
/// # .into()
/// # }
/// # wasm_bindgen_test_configure!(run_in_browser);
/// # #[wasm_bindgen_test]
/// # fn run() {
/// #     App::render_single(ui());
/// # }
/// ```
Render the StateVec to the DOM.
It will update if any element changes or even if the list changes automatically.

`enclose` is the `Component` inside which all of the elements will be present.
Render the StateVec to the DOM . It will update if any element changes or even if the list changes automatically . ` enclose ` is the ` Component ` inside which all of the elements will be present .
pub fn view<F, U, V>(&self, enclose: crate::Tag<U>, object: F) -> crate::Tag<U>
    where
        F: FnOnce(T) -> V,
        F: Clone + 'static,
        V: component::Component + 'static,
        U: html::elements::HtmlElement,
    {
        for i in self.value.read().iter() {
            enclose.node.push_child(object.clone()(i.clone()).into())
        }
        let node = enclose.node.clone();
        let (tx, rx) = unbuffered_channel();
        self.tx.write().push(tx);
        wasm_bindgen_futures::spawn_local(async move {
            while let Some(change) = rx.receive().await {
                match change {
                    Change::Insert(i, x) => node.insert_child(i, object.clone()(x).into()),
                    Change::Push(x) => node.push_child(object.clone()(x).into()),
                    Change::Remove(i) => node.remove_child(i),
                    Change::Pop => node.pop_child(),
                }
            }
        });
        enclose
    }
pub fn view < F , U , V > ( & self , enclose : crate :: Tag < U > , object : F ) -> crate :: Tag < U > where F : FnOnce ( T ) -> V , F : Clone + ' static , V : component :: Component + ' static , U : html :: elements :: HtmlElement , { for i in self . value . read ( ) . iter ( ) { enclose . node . push_child ( object . clone ( ) ( i . clone ( ) ) . into ( ) ) } let node = enclose . node . clone ( ) ; let ( tx , rx ) = unbuffered_channel ( ) ; self . tx . write ( ) . push ( tx ) ; wasm_bindgen_futures :: spawn_local ( async move { while let Some ( change ) = rx . receive ( ) . await { match change { Change :: Insert ( i , x ) => node . insert_child ( i , object . clone ( ) ( x ) . into ( ) ) , Change :: Push ( x ) => node . push_child ( object . clone ( ) ( x ) . into ( ) ) , Change :: Remove ( i ) => node . remove_child ( i ) , Change :: Pop => node . pop_child ( ) , } } } ) ; enclose }
Render the StateVec to the DOM.
Render the StateVec to the DOM .
&self
enclose
crate::Tag<U>
object
F
examples
None
use valerie::prelude::*;
None
use valerie::prelude::components::*;
None
use wasm_bindgen_test::*;
None
fn ui() -> node {
let vec = StateVec::with_capacity(10);
(0..10).for_each(|x| vec.push(StateAtomic::new(x))).


let vec = StateVec :: with_capacity ( 10 ) ; ( 0 .. 10 ) . for_each ( |x| vec . push ( StateAtomic :: new ( x ))) .
.into()
None
}
None
wasm_bindgen_test_configure!(run_in_browser);
None
#[wasm_bindgen_test]
None
fn run() {
None
app::render_single(ui());
None
}
None