소스 검색

feat: use dom to allow context injection

Jonathan Kelley 2 년 전
부모
커밋
e3a8e44a69
2개의 변경된 파일3개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 1
      examples/multiwindow.rs
  2. 1 3
      packages/desktop/src/desktop_context.rs

+ 2 - 1
examples/multiwindow.rs

@@ -12,7 +12,8 @@ fn app(cx: Scope) -> Element {
         div {
             button {
                 onclick: move |_| {
-                    window.new_window(popup, (), Default::default());
+                    let dom = VirtualDom::new_with_props(app, props);
+                    window.new_window(dom, Default::default());
                 },
                 "New Window"
             }

+ 1 - 3
packages/desktop/src/desktop_context.rs

@@ -4,7 +4,6 @@ use std::rc::Rc;
 use crate::eval::EvalResult;
 use crate::events::IpcMessage;
 use crate::Config;
-use dioxus_core::Component;
 use dioxus_core::ScopeState;
 use dioxus_core::VirtualDom;
 use serde_json::Value;
@@ -78,8 +77,7 @@ impl DesktopContext {
     }
 
     /// Create a new window using the props and window builder
-    pub fn new_window<T: 'static>(&self, app: Component<T>, props: T, cfg: Config) {
-        let dom = VirtualDom::new_with_props(app, props);
+    pub fn new_window<T: 'static>(&self, dom: VirtualDom, cfg: Config) {
         self.pending_windows.borrow_mut().push((dom, cfg));
         self.proxy
             .send_event(UserWindowEvent(EventData::NewWindow, self.id()))