Skip to main content

reactive_struct

Macro reactive_struct 

Source
macro_rules! reactive_struct {
    ($( $field:ident: $ty:ty = $init:expr ),* $(,)?) => { ... };
}
Expand description

Create a reactive struct with named fields.

Each field becomes a Ref<T>. This is useful for grouping related reactive state together.

§Examples

ⓘ
let state = reactive_struct! {
    count: Ref<i32> = ref_value(0),
    name: Ref<String> = ref_value(String::from("Hello")),
};

state.count.set(42);
state.name.set(String::from("World"));