Skip to content

Commit

Permalink
fix: correctly track updates to keyed fields in keyed iterator (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Dec 24, 2024
1 parent 28af33d commit 5f7edb4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions reactive_stores/src/keyed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,19 +450,15 @@ where
let inner = self.inner.reader()?;

let inner_path = self.inner.path().into_iter().collect();
let keys = self
.inner
.keys()
.expect("using keys on a store with no keys");
let keys = self.inner.keys()?;
let index = keys
.with_field_keys(
inner_path,
|keys| keys.get(&self.key),
|| self.inner.latest_keys(),
)
.flatten()
.map(|(_, idx)| idx)
.expect("reading from a keyed field that has not yet been created");
.map(|(_, idx)| idx)?;

Some(MappedMutArc::new(
inner,
Expand Down Expand Up @@ -654,8 +650,8 @@ where
#[track_caller]
fn into_iter(self) -> StoreFieldKeyedIter<Inner, Prev, K, T> {
// reactively track changes to this field
let trigger = self.get_trigger(self.path().into_iter().collect());
trigger.this.track();
self.update_keys();
self.track_field();

// get the current length of the field by accessing slice
let reader = self
Expand Down

0 comments on commit 5f7edb4

Please sign in to comment.