leptos

Macro memo

Source
memo!() { /* proc-macro */ }
Expand description

Generates a memo into a struct with a default getter.

Can be used to access deeply nested fields within a global state object.


#[derive(Default)]
pub struct Outer {
    count: i32,
    inner: Inner,
}

#[derive(Default)]
pub struct Inner {
    inner_count: i32,
    inner_name: String,
}

let outer_signal = RwSignal::new(Outer::default());

let count = memo!(outer_signal.count);

let inner_count = memo!(outer_signal.inner.inner_count);
let inner_name = memo!(outer_signal.inner.inner_name);