-
How can we pass a pub struct Session {
pub title: String,
#[store(key: DateTime<Local> = |chat_entry| chat_entry.date_added)]
pub chats: Vec<ChatEntry>,
} And we want to send the chats to this component: #[component]
pub fn Chats(#[prop(into)] chats: ???) -> impl IntoView {
view! {
<For each=move || chats key=|chat| chat.date_added() let(chat)>
. . .
</For>
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think this example can be helpful to you: https://github.com/leptos-rs/leptos/blob/main/examples/stores/src/lib.rs |
Beta Was this translation helpful? Give feedback.
-
rust-analyzer can give you the whole concrete type if you do something like #[component]
fn Todos(
store: Store<Todos>,
todos: KeyedSubfield<Store<Todos>, Todos, usize, Vec<Todo>>,
) -> impl IntoView {
view! {
<For
each=move || todos
key=|row| row.id().get()
let:todo
>
<TodoRow store todo/>
</For>
}
} There may be a way to express this using generics as well, but I played around a little and didn't find a good one. |
Beta Was this translation helpful? Give feedback.
rust-analyzer can give you the whole concrete type if you do something like
let x = session.chats();
and hover onx
, and then you can use that type. For example, in thestores
example:There may be a way to express this using generics as well, but I played around a little and didn't find a good one.