diff --git a/examples/stores/src/lib.rs b/examples/stores/src/lib.rs
index 0e1c99a79..350d1b104 100644
--- a/examples/stores/src/lib.rs
+++ b/examples/stores/src/lib.rs
@@ -95,7 +95,10 @@ pub fn App() -> impl IntoView {
-
+ // because `todos` is a keyed field, `store.todos()` returns a struct that
+ // directly implements IntoIterator, so we can use it in and
+ // it will manage reactivity for the store fields correctly
+
diff --git a/reactive_stores/src/keyed.rs b/reactive_stores/src/keyed.rs
index aae0b7ac4..197d35a7a 100644
--- a/reactive_stores/src/keyed.rs
+++ b/reactive_stores/src/keyed.rs
@@ -638,18 +638,21 @@ where
}
}
-impl KeyedSubfield
+impl IntoIterator for KeyedSubfield
where
Self: Clone,
for<'a> &'a T: IntoIterator,
- Inner: StoreField,
+ Inner: Clone + StoreField + 'static,
Prev: 'static,
K: Debug + Send + Sync + PartialEq + Eq + Hash + 'static,
- T: IndexMut,
+ T: IndexMut + 'static,
T::Output: Sized,
{
+ type Item = AtKeyed;
+ type IntoIter = StoreFieldKeyedIter;
+
#[track_caller]
- pub fn iter_keyed(self) -> StoreFieldKeyedIter {
+ fn into_iter(self) -> StoreFieldKeyedIter {
// reactively track changes to this field
let trigger = self.get_trigger(self.path().into_iter().collect());
trigger.track();