dioxus/docs/platforms/05-liveview.md

21 lines
888 B
Markdown
Raw Normal View History

2021-02-16 06:41:41 +00:00
## Liveview
2021-06-26 01:15:33 +00:00
2021-02-16 06:41:41 +00:00
With the Context, Subscription, and Asynchronous APIs, we've built Dioxus Liveview: a coupling of frontend and backend to deliver user experiences that do not require dedicated API development. Instead of building and maintaining frontend-specific API endpoints, components can directly access databases, server caches, and other services directly from the component.
These set of features are still experimental. Currently, we're still working on making these components more ergonomic
```rust
2021-07-18 16:39:32 +00:00
fn live_component(cx: &Context<()>) -> DomTree {
2021-02-16 06:41:41 +00:00
use_live_component(
2021-06-26 01:15:33 +00:00
cx,
2021-02-16 06:41:41 +00:00
// Rendered via the client
#[cfg(target_arch = "wasm32")]
|| html! { <div> {"Loading data from server..."} </div> },
// Renderered on the server
#[cfg(not(target_arch = "wasm32"))]
|| html! { <div> {"Server Data Loaded!"} </div> },
)
}
```