Chore: hoist example projects for discoverability (#2959)

* hoist example projects, remove oidc

* move over example projects from the separate repo

* Update ecommerce site to the latest version of dioxus

* update wifi scanner to 0.5

* drop the chatbot example; might be restored in a separate PR

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
Jonathan KelleyandEvan Almloff authored and GitHub committed 2024-09-16 09:11:33 -05:00
1 parent a9f87384f8
commit 983fcfc616
94 files changed
+2774 -7322

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
dist
target
static
.dioxus
+24
View File
@@ -0,0 +1,24 @@
[package]
name = "fullstack-streaming-example"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { workspace = true, features = ["fullstack"] }
serde = "1.0.159"
simple_logger = "4.2.0"
tracing-wasm = "0.2.1"
tracing.workspace = true
tracing-subscriber = "0.3.17"
futures = "0.3.30"
tokio = { workspace = true, optional = true }
futures-util.workspace = true
once_cell = "1.19.0"
[features]
default = []
server = ["dioxus/axum", "tokio"]
web = ["dioxus/web"]
+41
View File
@@ -0,0 +1,41 @@
use dioxus::prelude::*;
use futures::StreamExt;
use server_fn::codec::{StreamingText, TextStream};
fn app() -> Element {
let mut response = use_signal(String::new);
rsx! {
button {
onclick: move |_| async move {
response.write().clear();
if let Ok(stream) = test_stream().await {
response.write().push_str("Stream started\n");
let mut stream = stream.into_inner();
while let Some(Ok(text)) = stream.next().await {
response.write().push_str(&text);
}
}
},
"Start stream"
}
"{response}"
}
}
#[server(output = StreamingText)]
pub async fn test_stream() -> Result<TextStream, ServerFnError> {
let (tx, rx) = futures::channel::mpsc::unbounded();
tokio::spawn(async move {
loop {
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
let _ = tx.unbounded_send(Ok("Hello, world!".to_string()));
}
});
Ok(TextStream::new(rx))
}
fn main() {
launch(app)
}