Skip to content
Discussion options

You must be logged in to vote

With a Store, iter() and get() are the store's own methods and they hand you a child store per item instead of a reference to the item, which is why ele.1.name stops compiling. Store still implements Readable though, so if you call list.read() first you get a plain &Vec and your existing logic works unchanged:

let filtered_list = use_memo(move || {
    let f = filter_word().to_lowercase();
    list.read().iter().enumerate().filter(|(_, e)| e.name.to_lowercase().contains(&f)).map(|(i, _)| i).collect::<Vec<_>>()
});

Your render_item can stay exactly as it is, list.read() plus indexing works the same on a store as on a signal. Note I also lowercased the filter once outside the closure, your …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@fumagall
Comment options

@fahadiot
Comment options

Answer selected by fumagall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants