Skip to main content

Component

Trait Component 

Source
pub trait Component: Sized + 'static {
    const TEMPLATE_HASH: &'static str = "";
    const TEMPLATE_HTML: &'static str = "";

    // Required method
    fn mount(self) -> Result<Scope, JsValue>;

    // Provided methods
    fn mount_with(
        make: impl FnOnce(OwnerHandle) -> Self,
    ) -> Result<Scope, JsValue> { ... }
    fn try_mount_with(
        make: impl FnOnce(OwnerHandle) -> Result<Self, JsValue>,
    ) -> Result<Scope, JsValue> { ... }
    fn prepare(
        parent: &OwnerHandle,
        make: impl FnOnce(OwnerHandle) -> Result<Self, JsValue>,
    ) -> Result<Scope, JsValue> { ... }
}
Expand description

Implemented by the HTML build for each rust:component="RustType". State is shared by the generated closures without requiring Clone. Keep the returned scope alive; dropping it releases every binding.

Provided Associated Constants§

Source

const TEMPLATE_HASH: &'static str = ""

Source

const TEMPLATE_HTML: &'static str = ""

Required Methods§

Provided Methods§

Source

fn mount_with(make: impl FnOnce(OwnerHandle) -> Self) -> Result<Scope, JsValue>

Construct state after template validation, with its own weak lifetime.

Source

fn try_mount_with( make: impl FnOnce(OwnerHandle) -> Result<Self, JsValue>, ) -> Result<Scope, JsValue>

Source

fn prepare( parent: &OwnerHandle, make: impl FnOnce(OwnerHandle) -> Result<Self, JsValue>, ) -> Result<Scope, JsValue>

Prepare a child while owner-activation registrations wait. Ordinary constructor effects keep their immediate timing. Attach, then commit the returned scope; dropping it rolls back preparation. Used by outlets.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§