Make EventHandler copy (#2112)

* implement Copy for EventHandler
* implement from closure for event handler and remove special on prefix
* fix props implementation of EventHandler
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-03-19 19:48:53 -07:00
1 parent 4bb807a3ce
commit 58f7efafea
19 files changed
+755 -364

No files matched your search

+3 -6
View File
@@ -1,3 +1,4 @@
use crate::read_impls;
use crate::{read::Readable, Memo, ReadableRef};
use dioxus_core::prelude::ScopeId;
use generational_box::UnsyncStorage;
@@ -68,12 +69,6 @@ impl<T: PartialEq + 'static> Readable for GlobalMemo<T> {
}
}
impl<T: PartialEq + 'static> PartialEq for GlobalMemo<T> {
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(self, other)
}
}
/// Allow calling a signal with memo() syntax
///
/// Currently only limited to copy types, though could probably specialize for string/arc/rc
@@ -84,3 +79,5 @@ impl<T: PartialEq + Clone + 'static> Deref for GlobalMemo<T> {
Readable::deref_impl(self)
}
}
read_impls!(GlobalMemo<T> where T: PartialEq);
+3 -6
View File
@@ -6,6 +6,7 @@ use generational_box::UnsyncStorage;
use std::ops::Deref;
use super::get_global_context;
use crate::read_impls;
use crate::Signal;
/// A signal that can be accessed from anywhere in the application and created in a static
@@ -118,12 +119,6 @@ impl<T: 'static> Writable for GlobalSignal<T> {
}
}
impl<T: 'static> PartialEq for GlobalSignal<T> {
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(self, other)
}
}
/// Allow calling a signal with signal() syntax
///
/// Currently only limited to copy types, though could probably specialize for string/arc/rc
@@ -134,3 +129,5 @@ impl<T: Clone + 'static> Deref for GlobalSignal<T> {
Readable::deref_impl(self)
}
}
read_impls!(GlobalSignal<T>);