mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 09:54:41 -05:00
fix: improve support for keyed fields in ArcField<_>
This commit is contained in:
@@ -28,14 +28,14 @@ where
|
||||
{
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: &'static Location<'static>,
|
||||
path: StorePath,
|
||||
trigger: StoreFieldTrigger,
|
||||
path: Arc<dyn Fn() -> StorePath + Send + Sync>,
|
||||
get_trigger: Arc<dyn Fn(StorePath) -> StoreFieldTrigger + Send + Sync>,
|
||||
read: Arc<dyn Fn() -> Option<StoreFieldReader<T>> + Send + Sync>,
|
||||
pub(crate) write:
|
||||
Arc<dyn Fn() -> Option<StoreFieldWriter<T>> + Send + Sync>,
|
||||
keys: Arc<dyn Fn() -> Option<KeyMap> + Send + Sync>,
|
||||
track_field: Arc<dyn Fn() + Send + Sync>,
|
||||
notify: Arc<dyn Fn() + Send + Sync>,
|
||||
}
|
||||
|
||||
impl<T> Debug for ArcField<T>
|
||||
@@ -46,9 +46,7 @@ where
|
||||
let mut f = f.debug_struct("ArcField");
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
let f = f.field("defined_at", &self.defined_at);
|
||||
f.field("path", &self.path)
|
||||
.field("trigger", &self.trigger)
|
||||
.finish()
|
||||
f.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +104,7 @@ impl<T> StoreField for ArcField<T> {
|
||||
}
|
||||
|
||||
fn path(&self) -> impl IntoIterator<Item = StorePathSegment> {
|
||||
self.path.clone()
|
||||
(self.path)()
|
||||
}
|
||||
|
||||
fn reader(&self) -> Option<Self::Reader> {
|
||||
@@ -132,13 +130,13 @@ where
|
||||
ArcField {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: Location::caller(),
|
||||
path: value.path().into_iter().collect(),
|
||||
trigger: value.get_trigger(value.path().into_iter().collect()),
|
||||
path: Arc::new(move || value.path().into_iter().collect()),
|
||||
get_trigger: Arc::new(move |path| value.get_trigger(path)),
|
||||
read: Arc::new(move || value.reader().map(StoreFieldReader::new)),
|
||||
write: Arc::new(move || value.writer().map(StoreFieldWriter::new)),
|
||||
keys: Arc::new(move || value.keys()),
|
||||
track_field: Arc::new(move || value.track_field()),
|
||||
notify: Arc::new(move || value.notify()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,8 +150,10 @@ where
|
||||
ArcField {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: Location::caller(),
|
||||
path: value.path().into_iter().collect(),
|
||||
trigger: value.get_trigger(value.path().into_iter().collect()),
|
||||
path: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.path().into_iter().collect()
|
||||
}),
|
||||
get_trigger: Arc::new({
|
||||
let value = value.clone();
|
||||
move |path| value.get_trigger(path)
|
||||
@@ -174,6 +174,10 @@ where
|
||||
let value = value.clone();
|
||||
move || value.track_field()
|
||||
}),
|
||||
notify: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.notify()
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,8 +194,10 @@ where
|
||||
ArcField {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: Location::caller(),
|
||||
path: value.path().into_iter().collect(),
|
||||
trigger: value.get_trigger(value.path().into_iter().collect()),
|
||||
path: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.path().into_iter().collect()
|
||||
}),
|
||||
get_trigger: Arc::new({
|
||||
let value = value.clone();
|
||||
move |path| value.get_trigger(path)
|
||||
@@ -212,6 +218,10 @@ where
|
||||
let value = value.clone();
|
||||
move || value.track_field()
|
||||
}),
|
||||
notify: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.notify()
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,8 +237,10 @@ where
|
||||
ArcField {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: Location::caller(),
|
||||
path: value.path().into_iter().collect(),
|
||||
trigger: value.get_trigger(value.path().into_iter().collect()),
|
||||
path: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.path().into_iter().collect()
|
||||
}),
|
||||
get_trigger: Arc::new({
|
||||
let value = value.clone();
|
||||
move |path| value.get_trigger(path)
|
||||
@@ -249,6 +261,10 @@ where
|
||||
let value = value.clone();
|
||||
move || value.track_field()
|
||||
}),
|
||||
notify: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.notify()
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,8 +281,10 @@ where
|
||||
ArcField {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: Location::caller(),
|
||||
path: value.path().into_iter().collect(),
|
||||
trigger: value.get_trigger(value.path().into_iter().collect()),
|
||||
path: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.path().into_iter().collect()
|
||||
}),
|
||||
get_trigger: Arc::new({
|
||||
let value = value.clone();
|
||||
move |path| value.get_trigger(path)
|
||||
@@ -287,6 +305,10 @@ where
|
||||
let value = value.clone();
|
||||
move || value.track_field()
|
||||
}),
|
||||
notify: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.notify()
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,8 +329,10 @@ where
|
||||
ArcField {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: Location::caller(),
|
||||
path: value.path().into_iter().collect(),
|
||||
trigger: value.get_trigger(value.path().into_iter().collect()),
|
||||
path: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.path().into_iter().collect()
|
||||
}),
|
||||
get_trigger: Arc::new({
|
||||
let value = value.clone();
|
||||
move |path| value.get_trigger(path)
|
||||
@@ -329,6 +353,10 @@ where
|
||||
let value = value.clone();
|
||||
move || value.track_field()
|
||||
}),
|
||||
notify: Arc::new({
|
||||
let value = value.clone();
|
||||
move || value.notify()
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,12 +367,12 @@ impl<T> Clone for ArcField<T> {
|
||||
#[cfg(any(debug_assertions, leptos_debuginfo))]
|
||||
defined_at: self.defined_at,
|
||||
path: self.path.clone(),
|
||||
trigger: self.trigger.clone(),
|
||||
get_trigger: Arc::clone(&self.get_trigger),
|
||||
read: Arc::clone(&self.read),
|
||||
write: Arc::clone(&self.write),
|
||||
keys: Arc::clone(&self.keys),
|
||||
track_field: Arc::clone(&self.track_field),
|
||||
notify: Arc::clone(&self.notify),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +392,7 @@ impl<T> DefinedAt for ArcField<T> {
|
||||
|
||||
impl<T> Notify for ArcField<T> {
|
||||
fn notify(&self) {
|
||||
self.trigger.this.notify();
|
||||
(self.notify)()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user