fix tests

This commit is contained in:
Evan Almloff committed 2023-11-07 13:15:19 -06:00
1 parent 2731ca0b30
commit b3c5158524
6 files changed
+57 -12

No files matched your search

+6
View File
@@ -36,6 +36,12 @@ macro_rules! read_impls {
self.with(|v| Debug::fmt(v, f))
}
}
impl<T: PartialEq + 'static, S: $bound> PartialEq<T> for $ty<T, S> {
fn eq(&self, other: &T) -> bool {
self.with(|v| *v == *other)
}
}
};
}
+1
View File
@@ -15,3 +15,4 @@ pub(crate) mod signal;
pub use signal::*;
mod dependency;
pub use dependency::*;
pub use generational_box::{Storage, SyncStorage, UnsyncStorage};
+7 -5
View File
@@ -11,7 +11,9 @@ use dioxus_core::{
prelude::{current_scope_id, has_context, provide_context, schedule_update_any},
ScopeId, ScopeState,
};
use generational_box::{GenerationalBoxId, Mappable, MappableMut, Storage, UnsyncStorage};
use generational_box::{
GenerationalBoxId, Mappable, MappableMut, Storage, SyncStorage, UnsyncStorage,
};
use parking_lot::RwLock;
use crate::{get_effect_ref, CopyValue, EffectStackRef, EFFECT_STACK};
@@ -59,7 +61,7 @@ pub fn use_signal<T: 'static>(cx: &ScopeState, f: impl FnOnce() -> T) -> Signal<
/// use dioxus_signals::*;
///
/// fn App(cx: Scope) -> Element {
/// let mut count = use_signal(cx, || 0);
/// let mut count = use_signal_sync(cx, || 0);
///
/// // Because signals have automatic dependency tracking, if you never read them in a component, that component will not be re-rended when the signal is updated.
/// // The app component will never be rerendered in this example.
@@ -67,7 +69,7 @@ pub fn use_signal<T: 'static>(cx: &ScopeState, f: impl FnOnce() -> T) -> Signal<
/// }
///
/// #[component]
/// fn Child(cx: Scope, state: Signal<u32>) -> Element {
/// fn Child(cx: Scope, state: Signal<u32, SyncStorage>) -> Element {
/// let state = *state;
///
/// use_future!(cx, |()| async move {
@@ -90,8 +92,8 @@ pub fn use_signal<T: 'static>(cx: &ScopeState, f: impl FnOnce() -> T) -> Signal<
pub fn use_signal_sync<T: Send + Sync + 'static>(
cx: &ScopeState,
f: impl FnOnce() -> T,
) -> Signal<T, UnsyncStorage> {
*cx.use_hook(|| Signal::new(f()))
) -> Signal<T, SyncStorage> {
*cx.use_hook(|| Signal::new_maybe_sync(f()))
}
#[derive(Clone)]