Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Return empty iterator instead of panicking when the KeyedSubfield is disposed #3550

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions reactive_stores/src/keyed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,8 @@ where
{
fn latest_keys(&self) -> Vec<K> {
self.reader()
.expect("trying to update keys")
.deref()
.into_iter()
.map(|n| (self.key_fn)(n))
.collect()
.map(|r| r.deref().into_iter().map(|n| (self.key_fn)(n)).collect())
.unwrap_or_default()
}
}

Expand Down Expand Up @@ -654,13 +651,15 @@ where
self.track_field();

// get the current length of the field by accessing slice
let reader = self
.reader()
.expect("creating iterator from unavailable store field");
let reader = self.reader();

let keys = reader
.into_iter()
.map(|item| (self.key_fn)(item))
.collect::<VecDeque<_>>();
.map(|r| {
r.into_iter()
.map(|item| (self.key_fn)(item))
.collect::<VecDeque<_>>()
})
.unwrap_or_default();

// return the iterator
StoreFieldKeyedIter { inner: self, keys }
Expand Down
Loading