component

Attribute Macro component 

Source
#[component]
Expand description

Impl-level macro that automatically handles Component trait boilerplate.

This macro processes an impl block and:

  1. Collects all methods marked with #[effect]
  2. Generates helper methods for each effect
  3. Automatically creates the effects() method

§Example

#[component]
impl MyComponent {
    #[update]
    fn update(&self, ctx: &Context, msg: Msg, mut state: State) -> Action {
        // update logic
    }

    #[view]
    fn view(&self, ctx: &Context, state: State) -> Node {
        // view logic
    }

    #[effect]
    async fn timer(&self, ctx: &Context) {
        // async effect logic
    }
}

The macro will automatically generate the effects() method that collects all methods marked with #[effect].