1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[macro_export]
macro_rules! component {
    ($type:ty, $($e:tt)+) => {
        paste! {
            mod [<__component_ $type:lower>] {
                use super::*;

                extract_msg!{$($e)+}

                #[async_trait]
                impl Component<Msg> for $type {
                    fn update_bindings(&mut self, elems: Shared<Vec<web_sys::Element>>) {
                        extract_bindings!{self, elems, $($e)+}

                    }
                    async fn update(&mut self, msg: Msg) {
                        let lol = &mut *self;
                        extract_update!{lol, msg, $type, $($e)+}
                    }

                    fn view<F>(&self, f: F, bindings: Shared<Vec<web_sys::Element>>) -> web_sys::Element
                    where
                        F: Fn(Option<Msg>) + Clone + 'static
                    {
                        html! {self, f, bindings, $($e)+ }.into_element()
                    }
                }
            }
        }
    };
}