use maomi::prop::{BindingProp, BindingValue};
use maomi_dom::event::*;
#[component(Backend = DomBackend)]
struct MyChild {
template: template! {
<input value=&{ self.input_value } input=@value_changed() />
},
input_value: BindingValue<String>,
pub content: BindingProp<String>,
pub change: Event<()>,
}
impl Component for MyChild {
fn new() -> Self {
Self {
template: Default::default(),
input_value: Default::default(),
content: Default::default(),
change: Default::default(),
}
}
}
impl MyChild {
fn value_changed(this: ComponentEvent<Self, InputEvent>) {
this.task_with(|this, _| {
this.content.set(this.input_value.get());
this.change.trigger(&mut ());
});
}
}
#[component(Backend = DomBackend)]
struct MyWebsite {
template: template! {
<MyChild content=&{ self.content } change=@content_changed() />
<div> { self.content.get() } </div>
},
content: BindingValue<String>,
}
impl Component for MyWebsite {
fn new() -> Self {
Self {
template: Default::default(),
content: Default::default(),
}
}
}
impl MyWebsite {
fn content_changed(this: ComponentEvent<Self, ()>) {
this.task(|_| {});
}
}