feat: integrate serialization and string borrowing
This commit adds lifetimes to the diff and realdom methods so consumers may borrow the contents of the DOM for serialization or asynchronous modifications.
This commit is contained in:
1 parent
9813f23cdf
commit
f4fb5bb454
12 files changed
+480
-86
No files matched your search
@@ -5,6 +5,7 @@ use dioxus_core::prelude::*;
|
||||
use dioxus_core::virtual_dom::VirtualDom;
|
||||
use web_view::Handle;
|
||||
use web_view::{WVResult, WebView, WebViewBuilder};
|
||||
mod dom;
|
||||
|
||||
static HTML_CONTENT: &'static str = include_str!("./../../liveview/index.html");
|
||||
|
||||
@@ -22,6 +23,7 @@ pub struct WebviewRenderer<T> {
|
||||
/// The root component used to render the Webview
|
||||
root: FC<T>,
|
||||
}
|
||||
|
||||
enum InnerEvent {
|
||||
Initiate(Handle<()>),
|
||||
}
|
||||
@@ -68,8 +70,10 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
|
||||
.unwrap();
|
||||
|
||||
let mut vdom = VirtualDom::new_with_props(root, props);
|
||||
let edits = vdom.rebuild()?;
|
||||
let ref_edits = Arc::new(serde_json::to_string(&edits)?);
|
||||
let mut real_dom = dom::WebviewDom::new();
|
||||
vdom.rebuild(&mut real_dom)?;
|
||||
|
||||
let ref_edits = Arc::new(serde_json::to_string(&real_dom.edits)?);
|
||||
|
||||
loop {
|
||||
view.step()
|
||||
|
||||
Reference in new issue
Block a user