Crate silkenweb[][src]

Silkenweb is a library for writing reactive single page web apps

Features

  • Fine grained reactivity using signals
  • No VDOM
  • Uses plain Rust syntax rather than a macro DSL

Example: A Simple Counter

use silkenweb::{
    elements::{button, div, p},
    mount,
    signal::Signal,
};

fn main() {
    let count = Signal::new(0);
    let set_count = count.write();
    let inc = move |_, _| set_count.replace(|&i| i + 1);
    let count_text = count.read().map(|i| format!("{}", i));

    let app = div()
        .child(button().on_click(inc).text("+"))
        .child(p().text(count_text));

    mount("app", app);
}

Learning

Modules

accumulators

Accumulate reactive variables into a reactive total.

element_list

Manage reactive lists of DOM elements.

elements

All the HTML elements

memo

Memoize functions across frames.

signal

Signals are like variables that update their dependencies.

Macros

clone

Clone all the identifiers supplied as arguments.

Structs

Element

An HTML element.

ElementBuilder

Build an HTML element.

Traits

Builder

An HTML element builder.

DomElement

Get a raw Javascript, non-reactive DOM element.

Functions

after_render

Run a closure after the next render.

mount

Mount an element on the document.

render_updates

Render any pending updates.

tag

An HTML element tag.

unmount

Unmount an element.