Crate silkenweb

Source
Expand description

A library for building reactive web apps

§Overview

§Book

The Silkenweb book provides a high level introduction to Silkenweb’s main concepts.

§Quick Start

First, install the wasm32 target:

rustup target add wasm32-unknown-unknown

Then install trunk:

cargo install trunk --locked

To run the example counter:

cd examples/counter
trunk serve --open

§Feature Flags

§weak-refs

Use Javascript weak references to manage event callbacks. This improves performance but must be enabled in wasm-bindgen. See the trunk documentation for details on how to do this using data-weak-refs.

See caniuse for current browser support.

§declarative-shadow-dom

Print Declarative Shadow DOM when server side rendering. Hydration will correctly deal with shadow DOM regardless of this flag. See caniuse for browser support. Polyfills are available.

§css-transpile

Enable CSS transpilation for css!. This can significantly increase build time, so is presented as an opt-in feature.

§Learning

There’s extensive documentation on each module in this crate, along with many other examples in the examples folder.

Reactivity is provided by futures_signals. It would be helpful to familiarize yourself using futures_signals::tutorial.

Modules§

animation
Animation time signals.
attribute
Traits for defining attribute types.
document
Document utilities.
dom
An abstraction for the underlying DOM.
elements
HTML element types.
hydration
Hydrate the document with event handlers.
node
Generic DOM types.
prelude
Commonly used imports, all in one place.
property
Tools for working with Javascript properties.
router
URL based routing.
storage
Local and session storage.
task
Microtask and render queue tools.
time
Utilities for tacking time.
value
Abstract over the signal/value-ness of types.
window
Window utilities.

Macros§

clone
Clone all the identifiers supplied as arguments.
css
Define &str constants for each class in a CSS file.
custom_html_element
Define a custom html element.
dbg
This dbg! macro is a drop-in replacement for std::dbg
parent_element
Add child and text methods to an html element.
shadow_parent_element
Implement ShadowRootParent for the HTML element

Functions§

empty_str
intern_str
log_panics
Log any panic!s to the browser console. This should ideally be the very first thing that is called, but can be omitted safely. See console_error_panic_hook docs for more information.
mount
Shorthand for DefaultDom::mount

Attribute Macros§

cfg_browser

Derive Macros§

AriaElement
Derive AriaElement
ChildElement
Derive the traits needed for a blanket implmenetation of ChildElement.
Element
Derive Element.
ElementEvents
Derive ElementEvents
HtmlElement
Derive HtmlElement
HtmlElementEvents
Derive HtmlElementEvents
Value
Derive Value