Merge branch 'leptos_dom_v2' of https://github.com/jquesada2016/leptos into leptos_dom_v2
This commit is contained in:
commit
6d24af7748
|
@ -130,17 +130,19 @@ impl ComponentRepr {
|
|||
}
|
||||
|
||||
/// A user-defined `leptos` component.
|
||||
pub struct Component<F>
|
||||
pub struct Component<F, V>
|
||||
where
|
||||
F: FnOnce(Scope) -> View,
|
||||
F: FnOnce(Scope) -> V,
|
||||
V: IntoView,
|
||||
{
|
||||
name: Cow<'static, str>,
|
||||
children_fn: F,
|
||||
}
|
||||
|
||||
impl<F> Component<F>
|
||||
impl<F, V> Component<F, V>
|
||||
where
|
||||
F: FnOnce(Scope) -> View,
|
||||
F: FnOnce(Scope) -> V,
|
||||
V: IntoView,
|
||||
{
|
||||
/// Creates a new component.
|
||||
pub fn new(name: impl Into<Cow<'static, str>>, f: F) -> Self {
|
||||
|
@ -151,17 +153,18 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<F> IntoView for Component<F>
|
||||
impl<F, V> IntoView for Component<F, V>
|
||||
where
|
||||
F: FnOnce(Scope) -> View,
|
||||
F: FnOnce(Scope) -> V,
|
||||
V: IntoView,
|
||||
{
|
||||
fn into_view(self, cx: Scope) -> View {
|
||||
let Self { name, children_fn } = self;
|
||||
|
||||
let mut repr = ComponentRepr::new(name);
|
||||
|
||||
let (child, _) =
|
||||
cx.run_child_scope(|cx| cx.untrack(|| children_fn(cx)));
|
||||
let (child, disposer) =
|
||||
cx.run_child_scope(|cx| cx.untrack(|| children_fn(cx).into_view(cx)));
|
||||
|
||||
repr.children.push(child);
|
||||
|
||||
|
|
|
@ -119,9 +119,10 @@ impl<El: IntoElement> IntoChild for HtmlElement<El> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<F> IntoChild for Component<F>
|
||||
impl<F, V> IntoChild for Component<F, V>
|
||||
where
|
||||
F: FnOnce(Scope) -> View,
|
||||
F: FnOnce(Scope) -> V,
|
||||
V: IntoView,
|
||||
{
|
||||
fn into_child(self, cx: Scope) -> Child {
|
||||
Child::View(self.into_view(cx))
|
||||
|
|
Loading…
Reference in New Issue