[][src]Trait mogwai::view::interface::AttributeView

pub trait AttributeView {
    pub fn attribute<E: Into<Effect<String>>>(&mut self, name: &str, eff: E);
pub fn boolean_attribute<E: Into<Effect<bool>>>(
        &mut self,
        name: &str,
        eff: E
    ); }

AttributeViews can describe themselves with key value pairs.

Required methods

pub fn attribute<E: Into<Effect<String>>>(&mut self, name: &str, eff: E)[src]

Create a named attribute on the view that may change over time as a receiver receives a message. Here's an example that builds a gizmo with inital id and class values, and updates the class value whenever a message is received on a Receiver:

extern crate mogwai;
use mogwai::prelude::*;

let (tx, rx) = txrx::<String>();
let mut my_div: View<HtmlElement> = View::element("div");
my_div.attribute("id", "my_div");
my_div.attribute("class", ("hero_div", rx.branch_map(|class_update| {
    ["hero_div", class_update].join(" ")
})));

Alternatively you can use macros to define an equivalent view in RSX:

extern crate mogwai;
use mogwai::prelude::*;

let (tx, rx) = txrx::<String>();
let my_div:View<HtmlElement> = view! {
    <div id="my_div" class=("hero_div", rx.branch_map(|class_update| {
        ["hero_div", class_update].join(" ")
    })) />
};

pub fn boolean_attribute<E: Into<Effect<bool>>>(&mut self, name: &str, eff: E)[src]

Create (or remove) a boolean attribute on the view that may change its value every time the given receiver receives a message If eff contains a receiver and that receiver receives false it will respond by removing the attribute until it receives true. If eff is a single boolean value, either add or remove the attribute.

Loading content...

Implementors

impl<T: IsDomNode + AsRef<Node> + AsRef<Element> + 'static> AttributeView for ViewBuilder<T>[src]

impl<T: IsDomNode + AsRef<Element>> AttributeView for View<T>[src]

Loading content...