fix all broken examples (#1248)
This commit is contained in:
1 parent
6751d5941b
commit
d637ef187c
12 files changed
+29
-25
No files matched your search
@@ -13,7 +13,8 @@ use dioxus::prelude::*;
|
|||||||
use dioxus_desktop::Config;
|
use dioxus_desktop::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let vdom = VirtualDom::new(app);
|
let mut vdom = VirtualDom::new(app);
|
||||||
|
let _ = vdom.rebuild();
|
||||||
let content = dioxus_ssr::pre_render(&vdom);
|
let content = dioxus_ssr::pre_render(&vdom);
|
||||||
|
|
||||||
dioxus_desktop::launch_cfg(app, Config::new().with_prerendered(content));
|
dioxus_desktop::launch_cfg(app, Config::new().with_prerendered(content));
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
let read = div_element.read();
|
let read = div_element.read();
|
||||||
let client_rect = read.as_ref().map(|el| el.get_client_rect());
|
let client_rect = read.as_ref().map(|el| el.get_client_rect());
|
||||||
if let Some(client_rect) = client_rect {
|
if let Some(client_rect) = client_rect {
|
||||||
if let Ok(rect) = client_rect.await {
|
if let Ok(rect) = dbg!(client_rect.await) {
|
||||||
dimentions.set(rect);
|
dimentions.set(rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
//! will cause it to fetch a random dog image from the Dog API. Since the data
|
//! will cause it to fetch a random dog image from the Dog API. Since the data
|
||||||
//! is not ready immediately, we render some loading text.
|
//! is not ready immediately, we render some loading text.
|
||||||
//!
|
//!
|
||||||
//! We can achieve the majoirty of suspense functionality by composing "suspenseful"
|
//! We can achieve the majority of suspense functionality by composing "suspenseful"
|
||||||
//! primitives in our own custom components.
|
//! primitives in our own custom components.
|
||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|||||||
@@ -168,10 +168,8 @@ pub(crate) struct Query<V: DeserializeOwned> {
|
|||||||
impl<V: DeserializeOwned> Query<V> {
|
impl<V: DeserializeOwned> Query<V> {
|
||||||
/// Resolve the query
|
/// Resolve the query
|
||||||
pub async fn resolve(mut self) -> Result<V, QueryError> {
|
pub async fn resolve(mut self) -> Result<V, QueryError> {
|
||||||
match self.receiver.recv().await {
|
let result = self.result().await?;
|
||||||
Some(result) => V::deserialize(result).map_err(QueryError::Deserialize),
|
V::deserialize(result).map_err(QueryError::Deserialize)
|
||||||
None => Err(QueryError::Recv(RecvError::Closed)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a message to the query
|
/// Send a message to the query
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ use dioxus_fullstack::prelude::server_fn::set_server_url;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Set the url of the server where server functions are hosted.
|
// Set the url of the server where server functions are hosted.
|
||||||
set_server_url("http://127.0.0.0:8080");
|
set_server_url("http://127.0.0.1:8080");
|
||||||
dioxus_desktop::launch(app)
|
dioxus_desktop::launch(app)
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,16 @@
|
|||||||
// cargo run --bin server --features ssr
|
// cargo run --bin server --features ssr
|
||||||
// ```
|
// ```
|
||||||
|
|
||||||
|
use axum_desktop::*;
|
||||||
use dioxus_fullstack::prelude::*;
|
use dioxus_fullstack::prelude::*;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
|
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080));
|
||||||
|
|
||||||
|
PostServerData::register_explicit();
|
||||||
|
GetServerData::register_explicit();
|
||||||
|
|
||||||
axum::Server::bind(&addr)
|
axum::Server::bind(&addr)
|
||||||
.serve(
|
.serve(
|
||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! Run with:
|
//! Run with:
|
||||||
//!
|
//!
|
||||||
//! ```sh
|
//! ```sh
|
||||||
//! dx build --features web
|
//! dx build --features web --release
|
||||||
//! cargo run --features ssr
|
//! cargo run --features ssr --release
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![allow(non_snake_case, unused)]
|
#![allow(non_snake_case, unused)]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! Run with:
|
//! Run with:
|
||||||
//!
|
//!
|
||||||
//! ```sh
|
//! ```sh
|
||||||
//! dx build --features web
|
//! dx build --features web --release
|
||||||
//! cargo run --features ssr
|
//! cargo run --features ssr --release
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! Run with:
|
//! Run with:
|
||||||
//!
|
//!
|
||||||
//! ```sh
|
//! ```sh
|
||||||
//! dx build --features web
|
//! dx build --features web --release
|
||||||
//! cargo run --features ssr
|
//! cargo run --features ssr --release
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![allow(non_snake_case, unused)]
|
#![allow(non_snake_case, unused)]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! Run with:
|
//! Run with:
|
||||||
//!
|
//!
|
||||||
//! ```sh
|
//! ```sh
|
||||||
//! dx build --features web
|
//! dx build --features web --release
|
||||||
//! cargo run --features ssr
|
//! cargo run --features ssr
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! Run with:
|
//! Run with:
|
||||||
//!
|
//!
|
||||||
//! ```sh
|
//! ```sh
|
||||||
//! dx build --features web
|
//! dx build --features web --release
|
||||||
//! cargo run --features ssr
|
//! cargo run --features ssr --release
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![allow(non_snake_case, unused)]
|
#![allow(non_snake_case, unused)]
|
||||||
|
|||||||
@@ -131,18 +131,18 @@ pub fn render<R: Driver>(
|
|||||||
rdom.raw_world_mut().add_unique(query_engine);
|
rdom.raw_world_mut().add_unique(query_engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
renderer.update(&rdom);
|
|
||||||
let mut any_map = SendAnyMap::new();
|
|
||||||
any_map.insert(taffy.clone());
|
|
||||||
let mut rdom = rdom.write().unwrap();
|
|
||||||
let _ = rdom.update_state(any_map);
|
|
||||||
}
|
|
||||||
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
tokio::runtime::Builder::new_current_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()?
|
.build()?
|
||||||
.block_on(async {
|
.block_on(async {
|
||||||
|
{
|
||||||
|
renderer.update(&rdom);
|
||||||
|
let mut any_map = SendAnyMap::new();
|
||||||
|
any_map.insert(taffy.clone());
|
||||||
|
let mut rdom = rdom.write().unwrap();
|
||||||
|
let _ = rdom.update_state(any_map);
|
||||||
|
}
|
||||||
|
|
||||||
let mut terminal = (!cfg.headless).then(|| {
|
let mut terminal = (!cfg.headless).then(|| {
|
||||||
enable_raw_mode().unwrap();
|
enable_raw_mode().unwrap();
|
||||||
let mut stdout = std::io::stdout();
|
let mut stdout = std::io::stdout();
|
||||||
|
|||||||
Reference in new issue
Block a user