suspense works in desktop

This commit is contained in:
Jonathan Kelley committed 2022-11-16 11:48:47 -08:00
1 parent 66319cf6e2
commit 642b21f125
12 files changed
+180 -109

No files matched your search

+6 -9
View File
@@ -50,7 +50,7 @@ impl DesktopController {
let edits = dom.rebuild();
println!("got muts: {:#?}", edits);
// println!("got muts: {:#?}", edits);
{
let mut queue = edit_queue.lock().unwrap();
@@ -68,20 +68,15 @@ impl DesktopController {
let muts = dom
.render_with_deadline(tokio::time::sleep(
tokio::time::Duration::from_millis(100),
tokio::time::Duration::from_millis(16),
))
.await;
{
let mut queue = edit_queue.lock().unwrap();
for edit in muts.template_mutations {
queue.push(serde_json::to_string(&edit).unwrap());
}
for edit in muts.edits {
queue.push(serde_json::to_string(&edit).unwrap());
}
queue.push(serde_json::to_string(&muts.template_mutations).unwrap());
queue.push(serde_json::to_string(&muts.edits).unwrap());
drop(queue);
}
@@ -118,6 +113,8 @@ impl DesktopController {
let (_id, view) = self.webviews.iter_mut().next().unwrap();
println!("sending edits {:#?}", new_queue);
for edit in new_queue.drain(..) {
view.evaluate_script(&format!("window.interpreter.handleEdits({})", edit))
.unwrap();
-6
View File
@@ -181,12 +181,6 @@ pub fn launch_with_props<P: 'static + Send>(root: Component<P>, props: P, mut cf
index_file.clone(),
)
})
// passing edits via the custom protocol is faster than using eval, maybe?
.with_custom_protocol(String::from("edits"), move |r| {
//
// Ok(Response::body())
todo!()
})
.with_file_drop_handler(move |window, evet| {
file_handler
.as_ref()
+2
View File
@@ -18,6 +18,8 @@ pub(super) fn desktop_handler(
custom_head: Option<String>,
custom_index: Option<String>,
) -> Result<Response<Vec<u8>>> {
println!("loading request: {:?}", request.uri());
// Any content that uses the `dioxus://` scheme will be shuttled through this handler as a "special case".
// For now, we only serve two pieces of content which get included as bytes into the final binary.
let path = request.uri().to_string().replace("dioxus://", "");