mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
Fix cargo check on examples
This commit is contained in:
parent
0bd9692e45
commit
a72c035de4
42 changed files with 95 additions and 145 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -772,9 +772,6 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"axum 0.6.20",
|
||||
"dioxus",
|
||||
"dioxus-desktop",
|
||||
"dioxus-fullstack",
|
||||
"dioxus-router",
|
||||
"serde",
|
||||
"tokio",
|
||||
]
|
||||
|
@ -810,9 +807,6 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"axum 0.6.20",
|
||||
"dioxus",
|
||||
"dioxus-fullstack",
|
||||
"dioxus-router",
|
||||
"dioxus-web",
|
||||
"serde",
|
||||
"tokio",
|
||||
]
|
||||
|
|
|
@ -56,7 +56,7 @@ version = "0.4.3"
|
|||
|
||||
# dependencies that are shared across packages
|
||||
[workspace.dependencies]
|
||||
dioxus = { path = "packages/dioxus", version = "0.4.0" }
|
||||
dioxus = { path = "packages/dioxus", version = "0.4.0", default-features = false }
|
||||
dioxus-lib = { path = "packages/dioxus-lib", version = "0.4.0" }
|
||||
dioxus-core = { path = "packages/core", version = "0.4.2" }
|
||||
dioxus-core-macro = { path = "packages/core-macro", version = "0.4.0" }
|
||||
|
@ -66,9 +66,9 @@ dioxus-router-macro = { path = "packages/router-macro", version = "0.4.1" }
|
|||
dioxus-html = { path = "packages/html", default-features = false, version = "0.4.0" }
|
||||
dioxus-html-internal-macro = { path = "packages/html-internal-macro", version = "0.4.0" }
|
||||
dioxus-hooks = { path = "packages/hooks", version = "0.4.0" }
|
||||
dioxus-web = { path = "packages/web", version = "0.4.0" }
|
||||
dioxus-ssr = { path = "packages/ssr", version = "0.4.0" }
|
||||
dioxus-desktop = { path = "packages/desktop", version = "0.4.0" }
|
||||
dioxus-web = { path = "packages/web", version = "0.4.0", default-features = false }
|
||||
dioxus-ssr = { path = "packages/ssr", version = "0.4.0", default-features = false }
|
||||
dioxus-desktop = { path = "packages/desktop", version = "0.4.0", default-features = false }
|
||||
dioxus-mobile = { path = "packages/mobile", version = "0.4.0" }
|
||||
dioxus-interpreter-js = { path = "packages/interpreter", version = "0.4.0" }
|
||||
dioxus-liveview = { path = "packages/liveview", version = "0.4.0" }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use dioxus::prelude::*;
|
||||
use std::{collections::VecDeque, fmt::Debug, rc::Rc};
|
||||
|
||||
use dioxus::{events::*, html::MouseEvent, prelude::*};
|
||||
|
||||
fn main() {
|
||||
launch(app);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ fn app() -> Element {
|
|||
|
||||
let mut input_operator = move |key: &str| val.write().push_str(key);
|
||||
|
||||
let mut handle_key_down_event = move |evt: KeyboardEvent| match evt.key() {
|
||||
let handle_key_down_event = move |evt: KeyboardEvent| match evt.key() {
|
||||
Key::Backspace => {
|
||||
if !val().is_empty() {
|
||||
val.write().pop();
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use dioxus::desktop::{tao::dpi::LogicalSize, Config, WindowBuilder};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus::router::prelude::*;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ fn main() {
|
|||
fn app() -> Element {
|
||||
let mut value = use_signal(|| 0);
|
||||
let mut depth = use_signal(|| 0 as usize);
|
||||
let mut items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
||||
let items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
||||
|
||||
let state = use_memo(move || value() + 1);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use dioxus::desktop::{tao::dpi::PhysicalPosition, LogicalSize, WindowBuilder};
|
|||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop().with_cfg(make_config());
|
||||
LaunchBuilder::desktop().with_cfg(make_config()).launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
|
|
|
@ -4,9 +4,10 @@ use std::rc::Rc;
|
|||
use dioxus::{html::geometry::euclid::Rect, prelude::*};
|
||||
|
||||
fn main() {
|
||||
LaunchBuilder::desktop().with_cfg(
|
||||
dioxus::desktop::Config::default().with_custom_head(
|
||||
r#"
|
||||
LaunchBuilder::desktop()
|
||||
.with_cfg(
|
||||
dioxus::desktop::Config::default().with_custom_head(
|
||||
r#"
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
height: 100%;
|
||||
|
@ -19,16 +20,17 @@ fn main() {
|
|||
}
|
||||
</style>
|
||||
"#
|
||||
.to_owned(),
|
||||
),
|
||||
);
|
||||
.to_owned(),
|
||||
),
|
||||
)
|
||||
.launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let mut div_element = use_signal(|| None as Option<Rc<MountedData>>);
|
||||
let mut dimensions = use_signal(Rect::zero);
|
||||
|
||||
let mut read_dims = move |_| async move {
|
||||
let read_dims = move |_| async move {
|
||||
let read = div_element.read();
|
||||
let client_rect = read.as_ref().map(|el| el.get_client_rect());
|
||||
if let Some(client_rect) = client_rect {
|
||||
|
|
|
@ -39,7 +39,7 @@ fn app() -> Element {
|
|||
});
|
||||
|
||||
// use_resource will spawn a future that resolves to a value - essentially an async memo
|
||||
let slow_count = use_resource(move || async move {
|
||||
let _slow_count = use_resource(move || async move {
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
count() * 2
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let mut dom = VirtualDom::prebuilt(app);
|
||||
let dom = VirtualDom::prebuilt(app);
|
||||
let html = dioxus_ssr::render(&dom);
|
||||
|
||||
println!("{}", html);
|
||||
|
|
|
@ -15,7 +15,7 @@ fn app() -> Element {
|
|||
};
|
||||
}
|
||||
|
||||
let mut items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
||||
let items = use_memo(move || (0..depth()).map(|f| f as _).collect::<Vec<isize>>());
|
||||
|
||||
rsx! {
|
||||
button { onclick: move |_| state += 1, "Increment" }
|
||||
|
|
|
@ -35,7 +35,7 @@ fn Dice() -> Element {
|
|||
svg {
|
||||
view_box: "-1000 -1000 2000 2000",
|
||||
prevent_default: "onclick",
|
||||
onclick: move |e| value.set(thread_rng().gen_range(1..=6)),
|
||||
onclick: move |_| value.set(thread_rng().gen_range(1..=6)),
|
||||
rect { x: -1000, y: -1000, width: 2000, height: 2000, rx: 200, fill: "#aaa" }
|
||||
for ((x, y), _) in DOTS.iter().zip(active_dots.read().iter()).filter(|(_, &active)| active) {
|
||||
circle {
|
||||
|
|
|
@ -25,7 +25,7 @@ const STYLE: &str = include_str!("./assets/todomvc.css");
|
|||
|
||||
fn app() -> Element {
|
||||
let mut todos = use_signal(|| HashMap::<u32, TodoItem>::new());
|
||||
let mut filter = use_signal(|| FilterState::All);
|
||||
let filter = use_signal(|| FilterState::All);
|
||||
|
||||
let active_todo_count =
|
||||
use_memo(move || todos.read().values().filter(|item| !item.checked).count());
|
||||
|
@ -47,7 +47,7 @@ fn app() -> Element {
|
|||
filtered_todos
|
||||
});
|
||||
|
||||
let mut toggle_all = move |_| {
|
||||
let toggle_all = move |_| {
|
||||
let check = active_todo_count() != 0;
|
||||
for (_, item) in todos.write().iter_mut() {
|
||||
item.checked = check;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use dioxus::prelude::*;
|
||||
use dioxus_core::Element;
|
||||
use dioxus_desktop::{window, DesktopContext};
|
||||
use dioxus_desktop::DesktopContext;
|
||||
|
||||
fn main() {
|
||||
check_app_exits(check_html_renders);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use dioxus::prelude::*;
|
||||
use dioxus_html::{FocusData, KeyboardData, MouseData, WheelData};
|
||||
use std::{fmt::Debug, rc::Rc};
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
use dioxus::dioxus_core::RenderReturn;
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_tui::DioxusElementToNodeId;
|
||||
use dioxus_tui::Query;
|
||||
use dioxus_tui::Size;
|
||||
|
||||
fn main() {
|
||||
dioxus_tui::launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let mut hue = use_signal(|| 0.0);
|
||||
let mut brightness = use_signal(|| 0.0);
|
||||
let tui_query: Query = consume_context();
|
||||
let mapping: DioxusElementToNodeId = consume_context();
|
||||
|
||||
// disable templates so that every node has an id and can be queried
|
||||
rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
background_color: "hsl({hue}, 70%, {brightness}%)",
|
||||
onmousemove: move |evt| {
|
||||
todo!()
|
||||
// if let RenderReturn::Ready(node) = root_node() {
|
||||
// if let Some(id) = node.root_ids.borrow().first().cloned() {
|
||||
// let node = tui_query.get(mapping.get_node_id(id).unwrap());
|
||||
// let Size { width, height } = node.size().unwrap();
|
||||
// let pos = evt.inner().element_coordinates();
|
||||
// hue.set((pos.x as f32 / width as f32) * 255.0);
|
||||
// brightness.set((pos.y as f32 / height as f32) * 100.0);
|
||||
// }
|
||||
// }
|
||||
},
|
||||
"hsl({hue}, 70%, {brightness}%)"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ fn app() -> Element {
|
|||
let mut buttons = use_signal(|| "".to_string());
|
||||
let mut modifiers = use_signal(|| "".to_string());
|
||||
|
||||
let mut update_data = move |event: Event<MouseData>| {
|
||||
let update_data = move |event: Event<MouseData>| {
|
||||
page_coordinates.set(format!("{:?}", event.page_coordinates()));
|
||||
element_coordinates.set(format!("{:?}", event.element_coordinates()));
|
||||
|
||||
|
|
|
@ -5,12 +5,19 @@ use dioxus_tui::{Config, TuiContext};
|
|||
fn main() {
|
||||
for size in 1..=20usize {
|
||||
for _ in 0..10 {
|
||||
todo!()
|
||||
// dioxus_tui::launch_cfg(app, vec![size], Config::default().with_headless())
|
||||
let dom = VirtualDom::new(app).with_root_context(size);
|
||||
dioxus_tui::launch_vdom_cfg(dom, Config::default().with_headless())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let size = use_context::<usize>();
|
||||
rsx! {
|
||||
div { width: "100%", height: "100%", Grid { size } }
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn Box(x: usize, y: usize, hue: f32, alpha: f32) -> Element {
|
||||
let count = use_signal(|| 0);
|
||||
|
@ -87,13 +94,3 @@ fn Grid(size: usize) -> Element {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn app(props: usize) -> Element {
|
||||
rsx! {
|
||||
div{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
Grid{ size: props }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,10 @@ pub fn launch(app: fn() -> Element) {
|
|||
}
|
||||
|
||||
pub fn launch_cfg(app: fn() -> Element, cfg: Config) {
|
||||
launch_vdom_cfg(VirtualDom::new(app), cfg)
|
||||
}
|
||||
|
||||
pub fn launch_vdom_cfg(vdom: VirtualDom, cfg: Config) {
|
||||
dioxus_html::set_event_converter(Box::new(events::SerializedHtmlEventConverter));
|
||||
|
||||
render(cfg, |rdom, taffy, event_tx| {
|
||||
|
@ -34,7 +38,7 @@ pub fn launch_cfg(app: fn() -> Element, cfg: Config) {
|
|||
DioxusState::create(&mut rdom)
|
||||
};
|
||||
let dioxus_state = Rc::new(RwLock::new(dioxus_state));
|
||||
let mut vdom = VirtualDom::new(app)
|
||||
let vdom = vdom
|
||||
.with_root_context(TuiContext::new(event_tx))
|
||||
.with_root_context(Query::new(rdom.clone(), taffy.clone()))
|
||||
.with_root_context(DioxusElementToNodeId {
|
||||
|
|
|
@ -33,7 +33,7 @@ fn key_down() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
|
||||
|
@ -75,7 +75,7 @@ fn mouse_down() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
@ -111,7 +111,7 @@ fn mouse_up() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
@ -150,7 +150,7 @@ fn mouse_enter() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let mut render_count_handle = render_count.clone();
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
spawn(async move {
|
||||
|
@ -189,7 +189,7 @@ fn mouse_exit() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
@ -228,7 +228,7 @@ fn mouse_move() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
@ -267,7 +267,7 @@ fn wheel() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
@ -307,7 +307,7 @@ fn click() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
@ -346,7 +346,7 @@ fn context_menu() {
|
|||
dioxus_tui::launch_cfg(app, dioxus_tui::Config::new().with_headless());
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_count = use_signal(|| 0);
|
||||
let render_count = use_signal(|| 0);
|
||||
let tui_ctx: TuiContext = consume_context();
|
||||
let mut render_count_handle = render_count.clone();
|
||||
spawn(async move {
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::any::Any;
|
|||
use crate::prelude::*;
|
||||
|
||||
/// A builder for a fullstack app.
|
||||
#[must_use]
|
||||
pub struct LaunchBuilder<Cfg: 'static = (), ContextFn: ?Sized = ValidContext> {
|
||||
launch_fn: LaunchFn<Cfg, ContextFn>,
|
||||
contexts: Vec<Box<ContextFn>>,
|
||||
|
|
|
@ -7,18 +7,15 @@ publish = false
|
|||
[lib]
|
||||
|
||||
[dependencies]
|
||||
dioxus-desktop = { workspace = true, optional = true }
|
||||
dioxus = { workspace = true }
|
||||
dioxus-router = { workspace = true }
|
||||
dioxus-fullstack = { workspace = true }
|
||||
axum = { version = "0.6.12", optional = true }
|
||||
tokio = { workspace = true, features = ["full"], optional = true }
|
||||
serde = "1.0.159"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
ssr = ["axum", "tokio", "dioxus-fullstack/axum"]
|
||||
desktop = ["dioxus-desktop"]
|
||||
ssr = ["axum", "tokio", "dioxus/axum"]
|
||||
desktop = ["dioxus/desktop"]
|
||||
|
||||
[[bin]]
|
||||
name = "client"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#![allow(non_snake_case)]
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_fullstack::prelude::*;
|
||||
|
||||
pub fn app() -> Element {
|
||||
let mut count = use_signal(|| 0);
|
||||
|
|
|
@ -7,15 +7,12 @@ publish = false
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dioxus-web = { workspace = true, features = ["hydrate"], optional = true }
|
||||
dioxus = { workspace = true }
|
||||
dioxus-router = { workspace = true, features = ["fullstack"]}
|
||||
dioxus-fullstack = { workspace = true }
|
||||
dioxus = { workspace = true, features = ["router"] }
|
||||
axum = { version = "0.6.12", optional = true }
|
||||
tokio = {workspace = true, features = ["full"], optional = true }
|
||||
serde = { version = "1.0.159", features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
ssr = ["axum", "dioxus-fullstack/axum"]
|
||||
web = ["dioxus-fullstack/web", "dioxus-router/web"]
|
||||
ssr = ["axum", "dioxus/axum"]
|
||||
web = ["dioxus/web"]
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
//! ```
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus::router::prelude::*;
|
||||
use dioxus_fullstack::prelude::*;
|
||||
use dioxus_router::prelude::*;
|
||||
|
||||
fn main() {
|
||||
let config = LaunchBuilder::fullstack();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use dioxus_lib::prelude::*;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use std::any::Any;
|
||||
// use std::any::Any;
|
||||
use std::cell::Cell;
|
||||
use std::cell::Ref;
|
||||
use std::cell::RefCell;
|
||||
|
@ -23,13 +23,12 @@ use std::sync::Arc;
|
|||
///
|
||||
/// - dependencies: a tuple of references to values that are PartialEq + Clone
|
||||
#[must_use = "Consider using `cx.spawn` to run a future without reading its value"]
|
||||
pub fn use_server_future<T, F>(future: impl FnOnce() -> F) -> Option<UseServerFuture<T>>
|
||||
pub fn use_server_future<T, F>(_future: impl FnOnce() -> F) -> Option<UseServerFuture<T>>
|
||||
where
|
||||
T: 'static + Serialize + DeserializeOwned + Debug,
|
||||
F: Future<Output = T> + 'static,
|
||||
{
|
||||
todo!()
|
||||
|
||||
// let state = use_hook(move || UseServerFuture {
|
||||
// update: schedule_update(),
|
||||
// needs_regen: Cell::new(true),
|
||||
|
@ -110,7 +109,6 @@ pub struct UseServerFuture<T> {
|
|||
update: Arc<dyn Fn()>,
|
||||
needs_regen: Cell<bool>,
|
||||
task: Cell<Option<Task>>,
|
||||
dependencies: Vec<Box<dyn Any>>,
|
||||
value: Rc<RefCell<Option<Box<T>>>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ where
|
|||
UseFuture { task, state }
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct UseFuture {
|
||||
task: CopyValue<Task>,
|
||||
state: Signal<UseFutureState>,
|
||||
|
@ -58,10 +59,8 @@ impl UseFuture {
|
|||
}
|
||||
|
||||
/// Forcefully cancel a future
|
||||
pub fn cancel(&self) {
|
||||
// if let Some(task) = self.task.take() {
|
||||
// cx.remove_future(task);
|
||||
// }
|
||||
pub fn cancel(&mut self) {
|
||||
self.task.write().stop();
|
||||
}
|
||||
|
||||
/// Get the ID of the future in Dioxus' internal scheduler
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use dioxus_core::{prelude::use_drop, use_hook};
|
||||
use dioxus_core::prelude::use_drop;
|
||||
|
||||
#[deprecated(
|
||||
note = "Use `use_on_destroy` instead, which has the same functionality. \
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#![allow(missing_docs)]
|
||||
|
||||
use crate::use_signal;
|
||||
use dioxus_core::{
|
||||
prelude::{spawn, use_hook},
|
||||
ScopeState, Task,
|
||||
};
|
||||
use dioxus_core::{prelude::spawn, Task};
|
||||
use dioxus_signals::*;
|
||||
use futures_util::{future, pin_mut, FutureExt};
|
||||
use std::{any::Any, cell::Cell, future::Future, pin::Pin, rc::Rc, sync::Arc, task::Poll};
|
||||
use std::future::Future;
|
||||
|
||||
/// A future that resolves to a value.
|
||||
///
|
||||
|
@ -27,7 +25,7 @@ where
|
|||
F: Future<Output = T> + 'static,
|
||||
{
|
||||
let mut value = use_signal(|| None);
|
||||
let mut state = use_signal(|| UseResourceState::Pending);
|
||||
let state = use_signal(|| UseResourceState::Pending);
|
||||
|
||||
let task = use_signal(|| {
|
||||
// Create the user's task
|
||||
|
@ -61,6 +59,7 @@ where
|
|||
UseResource { task, value, state }
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct UseResource<T: 'static> {
|
||||
value: Signal<Option<T>>,
|
||||
task: Signal<Option<Task>>,
|
||||
|
|
|
@ -86,7 +86,10 @@ impl DioxusState {
|
|||
|
||||
/// A writer for mutations that can be used with the RealDom.
|
||||
pub struct DioxusNativeCoreMutationWriter<'a, V: FromAnyValue + Send + Sync = ()> {
|
||||
/// The realdom associated with this writer
|
||||
pub rdom: &'a mut RealDom<V>,
|
||||
|
||||
/// The state associated with this writer
|
||||
pub state: &'a mut DioxusState,
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn App<R: Routable>(props: AppProps<R>) -> Element
|
||||
#[allow(non_snake_case)]
|
||||
fn App<R: Routable>(_props: AppProps<R>) -> Element
|
||||
where
|
||||
<R as FromStr>::Err: std::fmt::Display,
|
||||
{
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_signals::Signal;
|
||||
|
||||
fn main() {
|
||||
// dioxus::desktop::launch(app);
|
||||
launch(app)
|
||||
}
|
||||
|
||||
// Because signal is never read in this component, this component will not rerun when the signal changes
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
// dioxus::desktop::launch(app);
|
||||
launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
// dioxus::desktop::launch(app);
|
||||
launch(app);
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
|
@ -14,12 +14,12 @@ enum ErrorComponent {
|
|||
fn app() -> Element {
|
||||
let mut error = use_signal(|| None as Option<ErrorComponent>);
|
||||
|
||||
render! {
|
||||
rsx! {
|
||||
match error() {
|
||||
Some(ErrorComponent::Read) => render! { Read {} },
|
||||
Some(ErrorComponent::ReadMut) => render! { ReadMut {} },
|
||||
Some(ErrorComponent::ReadDropped) => render! { ReadDropped {} },
|
||||
None => render! {
|
||||
Some(ErrorComponent::Read) => rsx! { Read {} },
|
||||
Some(ErrorComponent::ReadMut) => rsx! { ReadMut {} },
|
||||
Some(ErrorComponent::ReadDropped) => rsx! { ReadDropped {} },
|
||||
None => rsx! {
|
||||
button { onclick: move |_| error.set(Some(ErrorComponent::Read)), "Read" }
|
||||
button { onclick: move |_| error.set(Some(ErrorComponent::ReadMut)), "ReadMut" }
|
||||
button { onclick: move |_| error.set(Some(ErrorComponent::ReadDropped)), "ReadDropped"}
|
||||
|
@ -56,7 +56,7 @@ fn ReadDropped() -> Element {
|
|||
needs_update();
|
||||
}
|
||||
|
||||
render! {
|
||||
rsx! {
|
||||
if let Some(value) = signal() {
|
||||
"{value:?}"
|
||||
} else {
|
||||
|
@ -71,5 +71,5 @@ fn ReadDroppedSignalChild(parent_signal: SyncSignal<Option<SyncSignal<i32>>>) ->
|
|||
|
||||
use_hook(move || parent_signal.set(Some(signal)));
|
||||
|
||||
render! { "{signal}" }
|
||||
rsx! { "{signal}" }
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use dioxus::prelude::*;
|
||||
use dioxus_signals::*;
|
||||
|
||||
fn main() {
|
||||
// dioxus::desktop::launch(App);
|
||||
launch(app)
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App() -> Element {
|
||||
fn app() -> Element {
|
||||
let mut signal = use_signal(|| 0);
|
||||
let doubled = use_memo(move || signal * 2);
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use dioxus::prelude::*;
|
||||
use dioxus_signals::*;
|
||||
|
||||
fn main() {
|
||||
// dioxus::desktop::launch(App);
|
||||
launch(app);
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App() -> Element {
|
||||
fn app() -> Element {
|
||||
let mut signal = use_signal_sync(|| 0);
|
||||
|
||||
use_hook(|| {
|
||||
|
|
|
@ -4,7 +4,7 @@ use dioxus::prelude::*;
|
|||
use dioxus_signals::Signal;
|
||||
|
||||
fn main() {
|
||||
// dioxus::desktop::launch(app);
|
||||
launch(app);
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
|
|
|
@ -19,12 +19,12 @@ impl<R: Eq + Hash> Comparer<R> {
|
|||
///
|
||||
/// Generally, you shouldn't need to use this hook. Instead you can use [`crate::use_memo`]. If you have many values that you need to compare to a single value, this hook will change updates from O(n) to O(1) where n is the number of values you are comparing to.
|
||||
pub fn new(mut f: impl FnMut() -> R + 'static) -> Comparer<R> {
|
||||
let mut subscribers: CopyValue<FxHashMap<R, Signal<bool>>> =
|
||||
let subscribers: CopyValue<FxHashMap<R, Signal<bool>>> =
|
||||
CopyValue::new(FxHashMap::default());
|
||||
let mut previous = CopyValue::new(None);
|
||||
|
||||
Effect::new(move || {
|
||||
let mut subscribers = subscribers.read();
|
||||
let subscribers = subscribers.read();
|
||||
let mut previous = previous.write();
|
||||
|
||||
if let Some(previous) = previous.take() {
|
||||
|
@ -79,7 +79,7 @@ impl<R: Eq + Hash, S: Storage<SignalData<bool>>> Comparer<R, S> {
|
|||
|
||||
/// Returns a signal which is true when the value is equal to the value passed to this function.
|
||||
pub fn equal(&mut self, value: R) -> ReadOnlySignal<bool, S> {
|
||||
let mut subscribers = self.subscribers.write();
|
||||
let subscribers = self.subscribers.write();
|
||||
|
||||
match subscribers.get(&value) {
|
||||
Some(&signal) => signal.into(),
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::write::Writable;
|
|||
use crate::Write;
|
||||
use dioxus_core::prelude::{IntoAttributeValue, ScopeId};
|
||||
use generational_box::{AnyStorage, GenerationalRef, UnsyncStorage};
|
||||
use std::{cell::Ref, io::prelude::Read, mem::MaybeUninit, ops::Deref};
|
||||
use std::{cell::Ref, mem::MaybeUninit, ops::Deref};
|
||||
|
||||
use super::get_global_context;
|
||||
use crate::{MappedSignal, Signal};
|
||||
|
@ -43,6 +43,7 @@ impl<T: 'static> GlobalSignal<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Write this value
|
||||
pub fn write(&self) -> Write<T, UnsyncStorage> {
|
||||
self.signal().write()
|
||||
}
|
||||
|
|
|
@ -242,6 +242,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> Signal<T, S> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Unsubscribe this scope from the signal's effect list
|
||||
pub fn unsubscribe(&self, scope: ScopeId) {
|
||||
self.inner
|
||||
.read()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
mod cache;
|
||||
pub mod config;
|
||||
#[cfg(feature = "incremental")]
|
||||
mod fs_cache;
|
||||
#[cfg(feature = "incremental")]
|
||||
pub mod incremental;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue