Expand description
Vertigo is a library for building reactive web components.
It mainly consists of three parts:
- Virtual DOM - Lightweight representation of JavaScript DOM that can be used to optimally update real DOM
- Reactive dependencies - A graph of values and clients that can automatically compute what to refresh after one value change
- HTML/CSS macros - Allows to construct Virtual DOM nodes using HTML and CSS
Example
use std::cmp::PartialEq;
use vertigo::{Computed, Driver, VDomElement, Value, html, css_fn};
#[derive(PartialEq)]
pub struct State {
driver: Driver,
pub message: Value<String>,
}
impl State {
pub fn new(driver: &Driver) -> Computed<State> {
let state = State {
driver: driver.clone(),
message: driver.new_value("Hello world".to_string()),
};
driver.new_computed_from(state)
}
}
css_fn! { main_div, "
color: darkblue;
" }
pub fn render(app_state: &Computed<State>) -> VDomElement {
let state = app_state.get_value();
html! {
<div css={main_div()}>
"Message to the world: "
{state.message.get_value()}
</div>
}
}
More description soon! For now, to get started you may consider looking at the Tutorial.
Re-exports
pub use log;
Modules
Macros
Allows to create Css styles for virtual DOM.
Constructs a CSS block that can be manually pushed into existing Css styles instance.
Allows to define a Css styles factory function for virtual DOM.
Allows to define a Css styles factory function for virtual DOM based on existing function but with added new rules.
Allows to create VDomElement using HTML tags.
Structs
A structure similar to HashMap
but allows to provide a function create
for creating a new value if particular key doesn’t exists.
A reactive value that is read-only and computed by dependency graph.
CSS styles definition for Virtual DOM.
A graph of values and clients that can automatically compute what to refresh after one value change.
Main connection to vertigo facilities - dependencies and rendering client (the browser).
A struct used by driver to tidy things up on javascript side after a rust object goes out of scope.
Builder for simple requests.
Monotonically nondecrasing clock using a driver, similar to std::time::Instant.
Structure passed as a parameter to callback on on_key_down event.
A structure similar to Value but supports Loading/Error states and automatic refresh after defined amount of time.
Result from request made using RequestBuilder.
Virtual DOM node that represents a DOM element, a basic building block.
A reactive value. Basic building block of app state.
Represents websocket connection.
Enums
Css chunk, represented either as static or dynamic string.
Builder for typed requests (more complex version of FetchBuilder).
The state of the resource.
Websocket message type on which a websocket handler operates.
Traits
Ensures that vector of objects of this type is serializable and deserializable so can be used for defining a resource.
Ensures that this type is serializable and deserializable so can be used for defining a resource.
Functions
Starting point of the app.
Type Definitions
Result from request made using FetchBuilder.
Duration in seconds, returned from Instant methods.