fix the fullstack platform with the new launch API

This commit is contained in:
Evan Almloff committed 2024-01-18 10:19:39 -06:00
1 parent cb5a43c120
commit a323962a22
7 files changed
+281 -255

No files matched your search

+16 -1
View File
@@ -11,7 +11,7 @@ use tao::event::{Event, StartCause, WindowEvent};
///
/// This will block the main thread, and *must* be spawned on the main thread. This function does not assume any runtime
/// and is equivalent to calling launch_with_props with the tokio feature disabled.
pub fn launch_with_props_blocking(virtual_dom: VirtualDom, desktop_config: Config) {
pub fn launch_virtual_dom_blocking(virtual_dom: VirtualDom, desktop_config: Config) {
let (event_loop, mut app) = App::new(desktop_config, virtual_dom);
event_loop.run(move |window_event, _, control_flow| {
@@ -48,6 +48,21 @@ pub fn launch_with_props_blocking(virtual_dom: VirtualDom, desktop_config: Confi
})
}
/// Launches the WebView and runs the event loop, with configuration and root props.
pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) {
#[cfg(feature = "tokio")]
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(tokio::task::unconstrained(async move {
launch_virtual_dom_blocking(virtual_dom, desktop_config)
}));
#[cfg(not(feature = "tokio"))]
launch_virtual_dom_blocking(config, desktop_config)
}
/// Launches the WebView and runs the event loop, with configuration and root props.
pub fn launch(
root: fn() -> Element,