Expand description
Vertigo is a library for building reactive web components.
It mainly consists of four parts:
- Reactive dependencies - A graph of values and clients (micro-subscriptions) that can automatically compute what to refresh after one or more value change(s)
- Real DOM - No intermediate Virtual DOM mechanism is necessary
- HTML/CSS macros - Allows to construct Real DOM nodes using HTML and CSS
- Server-side rendering - Out of the box when using
vertigo-cli
§Example 1
use vertigo::{dom, DomNode, Value, bind, main};
#[main]
pub fn app() -> DomNode {
let count = Value::new(0);
let increment = bind!(count, |_| {
count.change(|value| {
*value += 1;
});
});
let decrement = bind!(count, |_| {
count.change(|value| {
*value -= 1;
});
});
dom! {
<html>
<head/>
<body>
<div>
<p>"Counter: " { count }</p>
<button on_click={decrement}>"-"</button>
<button on_click={increment}>"+"</button>
</div>
</body>
</html>
}
}
§Example 2
use vertigo::{css, component, DomNode, Value, dom, main};
#[component]
pub fn MyMessage(message: Value<String>) {
dom! {
<p>
"Message to the world: "
{ message }
</p>
}
}
#[main]
fn app() -> DomNode {
let message = Value::new("Hello world!".to_string());
let main_div = css!("
color: darkblue;
");
dom! {
<html>
<head/>
<body>
<div css={main_div}>
<MyMessage message={message} />
</div>
</body>
</html>
}
}
To get started you may consider looking at the Tutorial.
Short-links to most commonly used things:
- dom! - Build DomNode using RSX/rstml (HTML-like) syntax
- css! - Build Css using CSS-like syntax
- component - Wrap function to be used as component in RSX
- main - Wrap function to be vertigo entry-point
- get_driver - Access browser facilities
- bind! - Auto-clone variables before use
- Value - Read-write reactive value
- Computed - Read-only (computed) reactive value
- router::Router - Hash or history routing
Re-exports§
pub use log;
Modules§
- html_
entities - Constants of unicode signs labeled with HTML entities names
- inspect
- Methods for debugging or testing vertigo components by recreating HTML-like string from dom commands
- lazy_
cache - prelude
- router
- struct_
mut
Macros§
- bind
- Allows to conveniently clone values into closure.
- bind_rc
- Allows to create an event handler based on provided arguments which is wrapped in Rc
- bind_
spawn - Allows to create an event handler based on provided arguments which launches an asynchronous action
- computed_
tuple - Allows to create
Computed<T1, T2, ...>
out ofValue<T1>
,Value<T2>
, … - css
- Allows to create Css styles for usage in dom! macro.
- css_
block - Constructs a CSS block that can be manually pushed into existing Css styles instance.
- dom
- Allows to create DomNode using RSX/rstml (HTML-like) syntax.
- dom_
debug - Version of dom! macro that additionally emits compiler warning with generated code.
- dom_
element - Allows to create DomElement using HTML tags.
- include_
static - Allows to include a static file
- js
- Macro that allows to evaluate pseudo-JavaScript expressions.
- js_
inner - Used internally by js! macro.
- tw
- Allows to trace additional tailwind class names.
Structs§
- ApiImport
- AutoMap
- A structure similar to HashMap
but allows to provide a function
create
for creating a new value if particular key doesn’t exists. - Click
Event - Structure passed as a parameter to callback on on_key_down event.
- Computed
- A reactive value that is read-only and computed by dependency graph.
- Context
- Css
- CSS styles definition for use in DOM.
- Dependencies
- A graph of values and clients that can automatically compute what to refresh after one value change.
- DomComment
- A Real DOM representative - comment kind
- DomElement
- A Real DOM representative - element kind
- DomElement
Ref - A reference to DomElement.
- DomId
- DomText
- A Real DOM representative - text kind
- Driver
- Set of functions to communicate with the browser.
- Driver
Construct - Drop
File Event - Drop
File Item - Future
Box - Future
BoxSend - GraphId
- Instant
- Monotonically non-decreasing clock using a driver, similar to std::time::Instant.
- JsJson
Context - JsJson
Object Builder - KeyDown
Event - Structure passed as a parameter to callback on on_key_down event.
- Lazy
Cache - A structure similar to Value but supports Loading/Error states and automatic refresh after defined amount of time.
- Memory
Block - Request
Builder - Builder for typed requests.
- Request
Response - Result from request made using RequestBuilder.
- TwClass
- This represents a tailwind class. Use tw! macro to create one.
- Value
- A reactive value. Basic building block of app state.
- Websocket
Connection - Represents websocket connection.
Enums§
- Attr
Group Value - Attr
Value - Callback
- Callback1
- CssAttr
Value - CssGroup
- Css chunk, represented either as static or dynamic string.
- DomNode
- A Real DOM representative.
- Driver
DomCommand - Drop
Resource - A struct used by driver to tidy things up on javascript side after a rust object goes out of scope.
- Fetch
Method - JsJson
- JSON object serialized to travel between JS-WASM boundary.
- JsValue
- Represents a JavaScript value that can be passed to a JS function.
- Request
Body - Resource
- The state of the resource.
- Websocket
Message - Websocket message type on which a websocket handler operates.
Constants§
- VERTIGO_
MOUNT_ POINT_ PLACEHOLDER - Placeholder where to put public mount point at runtime (default /)
- VERTIGO_
PUBLIC_ BUILD_ PATH_ PLACEHOLDER - Placeholder where to put public build path at runtime (default /build)
Traits§
- Embed
Dom - Can be embedded into dom! macro
- JsJson
Deserialize - JsJson
Serialize - Reactive
- A trait that tells
Something<T>
is behaving like aValue<T>
. - ToComputed
- A trait allowing converting the type into computed.
Functions§
- from_
json - Deserialize from JsJson to T
- get_
driver - Getter for Driver singleton.
- start_
app - Starting point of the app (used by main macro, which is preferred)
- to_json
- Serialize T to JsJson
- transaction
- Do bunch of operations on dependency graph without triggering anything in between.
- wasm_
callback
Type Aliases§
- Attr
Group - Type interpreted as component’s dynamic attributes groups
- Fetch
Result - Result from request made using RequestBuilder.
- Instant
Type - Duration in seconds, returned from Instant methods.
Attribute Macros§
- component
- Macro which transforms a provided function into a component that can be used in dom! macro
- main
- Marco that marks an entry point of the app
Derive Macros§
- Auto
JsJson - Macro for creating
JsJson
from structures and structures fromJsJson
.