Move the document trait into a separate crate (#3035)

* add a default head method through eval
* remove the old document trait
* implement document for each platform
* pull out document into a dedicated crate to cut down on shared dependencies
---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-10-14 10:33:37 -07:00
1 parent 2b219c826c
commit 519ec9d294
91 files changed
+1113 -1044

No files matched your search

+3 -3
View File
@@ -19,7 +19,7 @@ fn app() -> Element {
// The `eval` is available in the prelude - and simply takes a block of JS.
// Dioxus' eval is interesting since it allows sending messages to and from the JS code using the `await dioxus.recv()`
// builtin function. This allows you to create a two-way communication channel between Rust and JS.
let mut eval = eval(
let mut eval = document::eval(
r#"
dioxus.send("Hi from JS!");
let msg = await dioxus.recv();
@@ -29,10 +29,10 @@ fn app() -> Element {
);
// Send a message to the JS code.
eval.send("Hi from Rust!".into()).unwrap();
eval.send("Hi from Rust!").unwrap();
// Our line on the JS side will log the message and then return "hello world".
let res = eval.recv().await.unwrap();
let res: String = eval.recv().await.unwrap();
// This will print "Hi from JS!" and "Hi from Rust!".
println!("{:?}", eval.await);