spawn hot reloading in a seperate thread

This commit is contained in:
Evan Almloff committed 2023-05-01 17:34:30 -05:00
1 parent 126ed2f9b8
commit 064bee4a9f
13 files changed
+106 -65

No files matched your search

@@ -13,15 +13,9 @@ dioxus-server = { path = "../../" }
axum = { version = "0.6.12", optional = true }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
execute = "0.2.12"
[features]
default = ["web"]
ssr = ["axum", "tokio", "dioxus-server/axum"]
web = ["dioxus-web"]
[profile.release]
lto = true
panic = "abort"
opt-level = 3
strip = true
codegen-units = 1
@@ -19,6 +19,19 @@ fn main() {
);
#[cfg(feature = "ssr")]
{
// Start hot reloading
hot_reload_init!(dioxus_hot_reload::Config::new().with_rebuild_callback(|| {
execute::shell("dioxus build --features web")
.spawn()
.unwrap()
.wait()
.unwrap();
execute::shell("cargo run --features ssr --no-default-features")
.spawn()
.unwrap();
true
}));
PostServerData::register().unwrap();
GetServerData::register().unwrap();
tokio::runtime::Runtime::new()
@@ -65,7 +78,7 @@ fn app(cx: Scope<AppProps>) -> Element {
}
}
},
"Run a server function"
"Run a server function! testing1234"
}
"Server said: {text}"
})
@@ -16,15 +16,9 @@ tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
tower-http = { version = "0.4.0", features = ["fs"], optional = true }
http = { version = "0.2.9", optional = true }
execute = "0.2.12"
[features]
default = ["web"]
ssr = ["axum", "tokio", "dioxus-server/axum", "tower-http", "http"]
web = ["dioxus-web", "dioxus-router/web"]
[profile.release]
lto = true
panic = "abort"
opt-level = 3
strip = true
codegen-units = 1
@@ -20,6 +20,19 @@ fn main() {
);
#[cfg(feature = "ssr")]
{
// Start hot reloading
hot_reload_init!(dioxus_hot_reload::Config::new().with_rebuild_callback(|| {
execute::shell("dioxus build --features web")
.spawn()
.unwrap()
.wait()
.unwrap();
execute::shell("cargo run --features ssr --no-default-features")
.spawn()
.unwrap();
true
}));
use axum::extract::State;
PostServerData::register().unwrap();
GetServerData::register().unwrap();
@@ -13,15 +13,9 @@ dioxus-server = { path = "../../" }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
salvo = { version = "0.37.9", optional = true }
execute = "0.2.12"
[features]
default = ["web"]
ssr = ["salvo", "tokio", "dioxus-server/salvo"]
web = ["dioxus-web"]
[profile.release]
lto = true
panic = "abort"
opt-level = 3
strip = true
codegen-units = 1
@@ -19,6 +19,19 @@ fn main() {
);
#[cfg(feature = "ssr")]
{
// Start hot reloading
hot_reload_init!(dioxus_hot_reload::Config::new().with_rebuild_callback(|| {
execute::shell("dioxus build --features web")
.spawn()
.unwrap()
.wait()
.unwrap();
execute::shell("cargo run --features ssr --no-default-features")
.spawn()
.unwrap();
true
}));
use salvo::prelude::*;
PostServerData::register().unwrap();
GetServerData::register().unwrap();
@@ -13,15 +13,9 @@ dioxus-server = { path = "../../" }
tokio = { version = "1.27.0", features = ["full"], optional = true }
serde = "1.0.159"
warp = { version = "0.3.3", optional = true }
execute = "0.2.12"
[features]
default = ["web"]
ssr = ["warp", "tokio", "dioxus-server/warp"]
web = ["dioxus-web"]
[profile.release]
lto = true
panic = "abort"
opt-level = 3
strip = true
codegen-units = 1
@@ -19,6 +19,19 @@ fn main() {
);
#[cfg(feature = "ssr")]
{
// Start hot reloading
hot_reload_init!(dioxus_hot_reload::Config::new().with_rebuild_callback(|| {
execute::shell("dioxus build --features web")
.spawn()
.unwrap()
.wait()
.unwrap();
execute::shell("cargo run --features ssr --no-default-features")
.spawn()
.unwrap();
true
}));
PostServerData::register().unwrap();
GetServerData::register().unwrap();
tokio::runtime::Runtime::new()
@@ -45,7 +58,7 @@ fn app(cx: Scope<AppProps>) -> Element {
cx.render(rsx! {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count += 10, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
button {
onclick: move |_| {