basic dioxus state
This commit is contained in:
Generated
+1
@@ -1525,6 +1525,7 @@ dependencies = [
|
||||
"dioxus",
|
||||
"dioxus-web",
|
||||
"manganis",
|
||||
"once_cell",
|
||||
"serde-wasm-bindgen 0.6.5",
|
||||
"serde_json",
|
||||
"wasm-bindgen",
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
dioxus = { version = "0.5.1", features = ["web"] }
|
||||
dioxus-web = "0.5.1"
|
||||
manganis = "0.2.2"
|
||||
once_cell = "1.19.0"
|
||||
serde-wasm-bindgen = "0.6.5"
|
||||
serde_json = "1.0.117"
|
||||
wasm-bindgen = "0.2.92"
|
||||
|
||||
+13
@@ -2,10 +2,23 @@
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
pub struct State {
|
||||
pub status: GlobalSignal<String>,
|
||||
}
|
||||
|
||||
pub static STATE: State = State {
|
||||
status: Signal::global(|| "Starting...".to_owned()),
|
||||
};
|
||||
|
||||
pub fn app() -> Element {
|
||||
use_coroutine(|_: UnboundedReceiver<()>| super::network_entrypoint());
|
||||
|
||||
let status = &STATE.status;
|
||||
rsx!(
|
||||
div {
|
||||
"Hello, World!"
|
||||
br {}
|
||||
"{status}"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod app;
|
||||
|
||||
use app::STATE;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::console;
|
||||
use web_sys::WebTransport;
|
||||
@@ -42,6 +43,8 @@ pub async fn network_entrypoint() {
|
||||
|
||||
console::log_1(&"Created WebTransportOptions!".into());
|
||||
|
||||
*STATE.status.write() = "Connecting to WebTransport...".into();
|
||||
|
||||
let transport = match WebTransport::new_with_options(
|
||||
"https://localhost:4433/?hostname=ohea.xyz&port=64738&username=test",
|
||||
&options,
|
||||
@@ -64,6 +67,8 @@ pub async fn network_entrypoint() {
|
||||
|
||||
console::log_1(&"Transport is ready.".into());
|
||||
|
||||
*STATE.status.write() = "Creating stream...".into();
|
||||
|
||||
let stream: web_sys::WebTransportBidirectionalStream =
|
||||
match wasm_bindgen_futures::JsFuture::from(transport.create_bidirectional_stream()).await {
|
||||
Ok(x) => x.into(),
|
||||
@@ -78,4 +83,6 @@ pub async fn network_entrypoint() {
|
||||
|
||||
console::log_1(&"Created bidirectional stream!".into());
|
||||
console::log_1(&stream.into());
|
||||
|
||||
//*STATE.status.write() = "Ready!".into();
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
use mumble_webtransport::{app, network_entrypoint};
|
||||
use mumble_webtransport::app;
|
||||
|
||||
pub fn main() {
|
||||
wasm_bindgen_futures::spawn_local(network_entrypoint());
|
||||
dioxus::launch(app::app);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user