mod children;
mod lifecycle;
mod properties;
mod scope;
use super::Html;
pub use children::*;
pub use properties::*;
pub(crate) use scope::Scoped;
pub use scope::{AnyScope, Scope, SendAsMessage};
use std::rc::Rc;
#[derive(Debug)]
pub struct Context<COMP: Component> {
pub(crate) scope: Scope<COMP>,
pub(crate) props: Rc<COMP::Properties>,
}
impl<COMP: Component> Context<COMP> {
#[inline]
pub fn link(&self) -> &Scope<COMP> {
&self.scope
}
#[inline]
pub fn props(&self) -> &COMP::Properties {
&*self.props
}
}
pub trait Component: Sized + 'static {
type Message: 'static;
type Properties: Properties;
fn create(ctx: &Context<Self>) -> Self;
#[allow(unused_variables)]
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
false
}
#[allow(unused_variables)]
fn changed(&mut self, ctx: &Context<Self>) -> bool {
true
}
fn view(&self, ctx: &Context<Self>) -> Html;
#[allow(unused_variables)]
fn rendered(&mut self, ctx: &Context<Self>, first_render: bool) {}
#[allow(unused_variables)]
fn destroy(&mut self, ctx: &Context<Self>) {}
}