pub(super) fn new_on_tokio<P: Send + 'static>(
        root: Component<P>,
        props: P,
        proxy: EventLoopProxy<UserWindowEvent>,
    ) -> Self {
        let edit_queue = Arc::new(Mutex::new(Vec::new()));
        let (sender, receiver) = futures_channel::mpsc::unbounded::<SchedulerMsg>();

        let pending_edits = edit_queue.clone();
        let return_sender = sender.clone();
        let desktop_context_proxy = proxy.clone();

        std::thread::spawn(move || {
            // We create the runtime as multithreaded, so you can still "spawn" onto multiple threads
            let runtime = tokio::runtime::Builder::new_multi_thread()
                .enable_all()
                .build()
                .unwrap();

            runtime.block_on(async move {
                let mut dom =
                    VirtualDom::new_with_props_and_scheduler(root, props, (sender, receiver));

                let window_context = DesktopContext::new(desktop_context_proxy);

                dom.base_scope().provide_context(window_context);

                let edits = dom.rebuild();

                edit_queue
                    .lock()
                    .unwrap()
                    .push(serde_json::to_string(&edits.edits).unwrap());

                // Make sure the window is ready for any new updates
                proxy.send_event(UserWindowEvent::Update).unwrap();

                loop {
                    dom.wait_for_work().await;

                    let muts = dom.work_with_deadline(|| false);

                    for edit in muts {
                        edit_queue
                            .lock()
                            .unwrap()
                            .push(serde_json::to_string(&edit.edits).unwrap());
                    }

                    let _ = proxy.send_event(UserWindowEvent::Update);
                }
            })
        });

        Self {
            pending_edits,
            sender: return_sender,
            webviews: HashMap::new(),
            is_ready: Arc::new(AtomicBool::new(false)),
            quit_app_on_close: true,
        }
    }
// Launch the virtualdom on its own thread managed by tokio
// returns the desktop state
Launch the virtualdom on its own thread managed by tokio
returns the desktop state
Launch the virtualdom on its own thread managed by tokio returns the desktop state
pub(super) fn new_on_tokio<P: Send + 'static>(
        root: Component<P>,
        props: P,
        proxy: EventLoopProxy<UserWindowEvent>,
    ) -> Self {
        let edit_queue = Arc::new(Mutex::new(Vec::new()));
        let (sender, receiver) = futures_channel::mpsc::unbounded::<SchedulerMsg>();
        let pending_edits = edit_queue.clone();
        let return_sender = sender.clone();
        let desktop_context_proxy = proxy.clone();
        std::thread::spawn(move || {
            // We create the runtime as multithreaded, so you can still "spawn" onto multiple threads
            let runtime = tokio::runtime::Builder::new_multi_thread()
                .enable_all()
                .build()
                .unwrap();
            runtime.block_on(async move {
                let mut dom =
                    VirtualDom::new_with_props_and_scheduler(root, props, (sender, receiver));
                let window_context = DesktopContext::new(desktop_context_proxy);
                dom.base_scope().provide_context(window_context);
                let edits = dom.rebuild();
                edit_queue
                    .lock()
                    .unwrap()
                    .push(serde_json::to_string(&edits.edits).unwrap());
                // Make sure the window is ready for any new updates
                proxy.send_event(UserWindowEvent::Update).unwrap();
                loop {
                    dom.wait_for_work().await;
                    let muts = dom.work_with_deadline(|| false);
                    for edit in muts {
                        edit_queue
                            .lock()
                            .unwrap()
                            .push(serde_json::to_string(&edit.edits).unwrap());
                    }
                    let _ = proxy.send_event(UserWindowEvent::Update);
                }
            })
        });
        Self {
            pending_edits,
            sender: return_sender,
            webviews: HashMap::new(),
            is_ready: Arc::new(AtomicBool::new(false)),
            quit_app_on_close: true,
        }
    }
pub ( super ) fn new_on_tokio < P : Send + ' static > ( root : Component < P > , props : P , proxy : EventLoopProxy < UserWindowEvent > , ) -> Self { let edit_queue = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ; let ( sender , receiver ) = futures_channel :: mpsc :: unbounded :: < SchedulerMsg > ( ) ; let pending_edits = edit_queue . clone ( ) ; let return_sender = sender . clone ( ) ; let desktop_context_proxy = proxy . clone ( ) ; std :: thread :: spawn ( move | | { // We create the runtime as multithreaded, so you can still "spawn" onto multiple threads let runtime = tokio :: runtime :: Builder :: new_multi_thread ( ) . enable_all ( ) . build ( ) . unwrap ( ) ; runtime . block_on ( async move { let mut dom = VirtualDom :: new_with_props_and_scheduler ( root , props , ( sender , receiver ) ) ; let window_context = DesktopContext :: new ( desktop_context_proxy ) ; dom . base_scope ( ) . provide_context ( window_context ) ; let edits = dom . rebuild ( ) ; edit_queue . lock ( ) . unwrap ( ) . push ( serde_json :: to_string ( & edits . edits ) . unwrap ( ) ) ; // Make sure the window is ready for any new updates proxy . send_event ( UserWindowEvent :: Update ) . unwrap ( ) ; loop { dom . wait_for_work ( ) . await ; let muts = dom . work_with_deadline ( | | false ) ; for edit in muts { edit_queue . lock ( ) . unwrap ( ) . push ( serde_json :: to_string ( & edit . edits ) . unwrap ( ) ) ; } let _ = proxy . send_event ( UserWindowEvent :: Update ) ; } } ) } ) ; Self { pending_edits , sender : return_sender , webviews : HashMap :: new ( ) , is_ready : Arc :: new ( AtomicBool :: new ( false ) ) , quit_app_on_close : true , } }
Launch the virtualdom on its own thread managed by tokio
returns the desktop state
Launch the virtualdom on its own thread managed by tokio returns the desktop state
root
Component<P>
props
P
proxy
EventLoopProxy<UserWindowEvent>
root
Component<P>
props
P
proxy
EventLoopProxy<UserWindowEvent>