use kobold::prelude::*;
use kobold::diff::fence;
struct User {
id: usize,
name: String,
email: String,
}
#[component]
fn UserRow(user: &User) -> impl View + '_ {
fence(user.id, || view! {
// This row is only re-rendered if `user.id` has changed
<tr>
<td>{ user.id }</td>
// Assuming that `name` never changes for a `User`
// we can disable diffing here with the `use` keyword.
<td>{ use &user.name }</td>
<td>{ use &user.email }</td>
</tr>
})
}
This PR adds the
kobold::diff::fence
function that guards some innerView
against changes, unless it'sguard
value has changed. Signature:Example: