sycamore::web::bind

Trait BindDescriptor

pub trait BindDescriptor {
    type Event: EventDescriptor;
    type ValueTy: Into<JsValue> + Clone;

    const TARGET_PROPERTY: &'static str;
    const CONVERT_FROM_JS: for<'a> fn(_: &'a JsValue) -> Option<Self::ValueTy>;
}
Expand description

Description for a bind-able attribute/property.

Required Associated Constants§

const TARGET_PROPERTY: &'static str

The name of the property to which we are binding.

const CONVERT_FROM_JS: for<'a> fn(_: &'a JsValue) -> Option<Self::ValueTy>

Function for converting from JS to Rust type.

Required Associated Types§

type Event: EventDescriptor

The event which we listen to to update the value.

type ValueTy: Into<JsValue> + Clone

The value of the signal that drives the attribute/property.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl BindDescriptor for checked

§

const TARGET_PROPERTY: &'static str = "checked"

§

const CONVERT_FROM_JS: for<'a> fn(_: &'a JsValue) -> Option<<checked as BindDescriptor>::ValueTy> = {sycamore_web::wasm_bindgen::JsValue::as_bool as for<'a> fn(&'a sycamore_web::wasm_bindgen::JsValue) -> std::option::Option<<sycamore_web::bind::checked as sycamore_web::bind::BindDescriptor>::ValueTy>}

§

type Event = change

§

type ValueTy = bool

§

impl BindDescriptor for value

§

const TARGET_PROPERTY: &'static str = "value"

§

const CONVERT_FROM_JS: for<'a> fn(_: &'a JsValue) -> Option<<value as BindDescriptor>::ValueTy> = {sycamore_web::wasm_bindgen::JsValue::as_string as for<'a> fn(&'a sycamore_web::wasm_bindgen::JsValue) -> std::option::Option<<sycamore_web::bind::value as sycamore_web::bind::BindDescriptor>::ValueTy>}

§

type Event = input

§

type ValueTy = String

§

impl BindDescriptor for valueAsNumber

§

const TARGET_PROPERTY: &'static str = "valueAsNumber"

§

const CONVERT_FROM_JS: for<'a> fn(_: &'a JsValue) -> Option<<valueAsNumber as BindDescriptor>::ValueTy> = {sycamore_web::wasm_bindgen::JsValue::as_f64 as for<'a> fn(&'a sycamore_web::wasm_bindgen::JsValue) -> std::option::Option<<sycamore_web::bind::valueAsNumber as sycamore_web::bind::BindDescriptor>::ValueTy>}

§

type Event = input

§

type ValueTy = f64