feat: static node infrastructure and ssr changes
This commit is contained in:
1 parent
975fa566f9
commit
9abb0470b7
34 files changed
+1022
-855
No files matched your search
+14
-12
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! The example from the README.md
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::{pin::Pin, time::Duration};
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use futures::Future;
|
||||
@@ -19,23 +19,25 @@ struct DogApi {
|
||||
|
||||
const ENDPOINT: &str = "https://dog.ceo/api/breeds/image/random";
|
||||
|
||||
struct Ex(Pin<Box<dyn Future<Output = ()> + 'static>>);
|
||||
static App: FC<()> = |cx| {
|
||||
// let mut count = use_state(cx, || 0);
|
||||
let mut count = use_state(cx, || 0);
|
||||
let mut fut = cx.use_hook(
|
||||
move || {
|
||||
Ex(Box::pin(async {
|
||||
Box::pin(async {
|
||||
//
|
||||
let mut tick = 0;
|
||||
loop {
|
||||
match surf::get(ENDPOINT).recv_json::<DogApi>().await {
|
||||
Ok(_) => (),
|
||||
Err(_) => (),
|
||||
}
|
||||
async_std::task::sleep(Duration::from_millis(250)).await;
|
||||
log::debug!("ticking forward... {}", tick);
|
||||
tick += 1;
|
||||
// match surf::get(ENDPOINT).recv_json::<DogApi>().await {
|
||||
// Ok(_) => (),
|
||||
// Err(_) => (),
|
||||
// }
|
||||
}
|
||||
})
|
||||
as Pin<Box<dyn Future<Output = ()> + 'static>>)
|
||||
}) as Pin<Box<dyn Future<Output = ()> + 'static>>
|
||||
},
|
||||
|h| &mut h.0,
|
||||
|h| h,
|
||||
|_| {},
|
||||
);
|
||||
|
||||
@@ -43,7 +45,7 @@ static App: FC<()> = |cx| {
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
||||
h1 {"it's working somewhat properly"}
|
||||
}
|
||||
})
|
||||
};
|
||||
Reference in new issue
Block a user