#[component]Expand description
Publishes an implementation’s lifecycle hooks and actions to the browser.
ⓘ
#[component]
impl Counter {
fn mount(&mut self, count: Option<i32>) {
self.count = count.unwrap_or(0);
}
fn increment(&mut self, by: i32) {
self.count += by;
}
}Class options go on the attribute: layout = "…", title = "…", transition = "…", lazy,
defer, and isolate. Method options go on the method:
| Method attribute | Meaning |
|---|---|
on = "event" | The method listens for the event |
renderless | The method’s response carries no HTML |
json | The method answers with JSON |
async | The browser sends the call ahead of the others |
authorize(path::to::policy) | The policy decides whether the call may run |