Enum respo::RespoNode

source ·
pub enum RespoNode<T>where
    T: Debug + Clone,
{ Component(StringVec<RespoEffect>, Box<RespoNode<T>>), Element { name: String, attrs: HashMap<String, String>, event: HashMap<String, RespoListenerFn<T>>, style: RespoStyle, children: Vec<(RespoIndexKey, RespoNode<T>)>, }, Referenced(Rc<RespoNode<T>>), }
Expand description

an Element or a Component

Variants§

§

Component(StringVec<RespoEffect>, Box<RespoNode<T>>)

§

Element

Fields

§name: String

tagName

§style: RespoStyle

inlines styles, partially typed. there’s also a macro called static_styles for inserting CSS rules

§children: Vec<(RespoIndexKey, RespoNode<T>)>

each child as a key like a string, by default generated from index, they are used in diffing, so it’s better to be distinct, although not required to be.

corresponding to DOM elements

§

Referenced(Rc<RespoNode<T>>)

Implementations§

create an element node

create a new component

attach styles

element.style(RespoStyle::default().margin(10))

imparative way of updating style

element.modify_style(|s| {
  if data > 1 {
    s.color(CssColor::Red);
  }
});

set an attribute on element

set an attribute on element, but using None indicates noting

handle keydown event

handle focus event

handle change event

attach a listener by event name(only a small set of events are supported)

add children elements, index key are generated from index number

add children elements, with index keys specified

add an effect on component

add an empty args effect on component, which does not update

add a list of effects on component

attach a class name for adding styles

attach an optional class name for adding styles

attach a class name, controlled by a boolean

attach a list of class names for adding styles

writes innerText

writes innerHTML

writes value

wrap with a Rc<RefCell<T>> to enable memory reuse and skipping in diff

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.