Fix cargo check on examples

This commit is contained in:
Jonathan Kelley committed 2024-01-30 17:59:57 -08:00
1 parent 0bd9692e45
commit a72c035de4
42 files changed
+95 -145

No files matched your search

+1 -2
View File
@@ -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 -1
View File
@@ -1,7 +1,7 @@
use dioxus::prelude::*;
fn main() {
// dioxus::desktop::launch(app);
launch(app);
}
fn app() -> Element {
+8 -8
View File
@@ -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}" }
}
+2 -4
View File
@@ -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);
+2 -4
View File
@@ -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)]
+3 -3
View File
@@ -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(),
+2 -1
View File
@@ -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()
}
+1
View File
@@ -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()