Skip to content

struct

Bind

pub struct Bind {
    /* private fields */
}

Fluent scope builder for component setup functions.

Methods

new

pub fn new(props: &Props) -> Bind

Start binding a component's scope from its props.

val

pub fn val<V: Into<Value>>(self, name: &str, f: impl Fn(&Props) -> V + 'static) -> Bind

Bind a value computed from props (re-evaluated on every render).

opt

pub fn opt(self, name: &'static str) -> Bind

Bind a prop as-is (Null when absent).

text

pub fn text(self, name: &'static str, default: &'static str) -> Bind

Bind a text prop with a default.

num

pub fn num(self, name: &'static str, default: f64) -> Bind

Bind name to the number prop name (a prop's value updates it), or default.

classes

pub fn classes(self, name: &str, own: impl Fn(&Props) -> String + 'static) -> Bind

name = own classes merged with the caller's class (theirs win).

flag

pub fn flag(self, name: &'static str, default: bool) -> Bind

Bind name to whether prop name is set and truthy, or default.

signal

pub fn signal<T: Clone + Into<Value> + 'static>(self, name: &str, s: &Signal<T>) -> Bind

Bind name to the signal s.

value

pub fn value(self, name: &str, v: impl Into<Value>) -> Bind

Bind name to the fixed value v.

emit

pub fn emit(self, handler: &str, event: &'static str) -> Bind

A template handler that re-emits as the component event event.

on

pub fn on(self, name: &str, f: impl Fn(&Props, &Event) + 'static) -> Bind

Bind handler name to f, which gets the component's props and the event.

done

pub fn done(self) -> Scope

The scope bound so far.