From aa1a928b91ec8cc517a3c365d4e488eeb0bb4869 Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:40:48 +0200 Subject: [PATCH] Make VirtualDom constructor take an `impl Fn()` instead of a function pointer (#2583) * feat: don't use function pointer to allow capturing context * fix: make virtualdom factory take a function of type ComponentFunction with empty props * fix: remove redundant generic arg * fix: bruh * fix: bruh --- packages/core/src/virtual_dom.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index ea4920cde..c727cc4d1 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -254,7 +254,7 @@ impl VirtualDom { /// ``` /// /// Note: the VirtualDom is not progressed, you must either "run_with_deadline" or use "rebuild" to progress it. - pub fn new(app: fn() -> Element) -> Self { + pub fn new Element + Clone + 'static>(app: F) -> Self { Self::new_with_props(app, ()) } @@ -313,7 +313,7 @@ impl VirtualDom { } /// Create a new virtualdom and build it immediately - pub fn prebuilt(app: fn() -> Element) -> Self { + pub fn prebuilt Element + Clone + 'static>(app: F) -> Self { let mut dom = Self::new(app); dom.rebuild_in_place(); dom