#[derive(Store)]Expand description
Derive macro for the Store trait
Automatically implements the Store trait for structs.
§Requirements
Your struct must derive Default. The macro will implement the Store trait
using the struct’s type name as the store identifier.
§Example
ⓘ
use revue::prelude::*;
use revue_macros::Store;
#[derive(Store, Default)]
struct CounterStore {
count: Signal<i32>,
}
impl CounterStore {
fn new() -> Self {
Self {
count: signal(0),
}
}
fn increment(&self) {
self.count.update(|c| *c += 1);
}
}
// Use the store
let counter = use_store::<CounterStore>();
counter.increment();§Generated Implementation
The macro generates:
id()method that returns a unique ID based on the type namename()method that returns the struct nameget_state()andget_getters()methods (basic implementations)