dioxus/packages/liveview
Jon Kelley d9546d9504
Renderers are now packages, not features. (#387)
* feat: use synchronous router design

* feat: function to get router out of dom

* chore: restructure workspace to use renderers as packages, not features
2022-07-09 15:15:20 -04:00
..
.vscode feat: liveview working with warp 2022-03-15 01:02:44 -04:00
examples Renderers are now packages, not features. (#387) 2022-07-09 15:15:20 -04:00
src Merge branch 'master' of https://github.com/DioxusLabs/dioxus into rusty-events 2022-06-28 21:09:20 +03:00
Cargo.toml Renderers are now packages, not features. (#387) 2022-07-09 15:15:20 -04:00
CHANGELOG.md Release dioxus-core v0.1.3, dioxus-core-macro v0.1.2, dioxus-html v0.1.0, dioxus-desktop v0.0.0, dioxus-hooks v0.1.3, dioxus-liveview v0.1.0, dioxus-mobile v0.0.0, dioxus-router v0.1.0, dioxus-ssr v0.1.0, dioxus-web v0.0.0, dioxus v0.1.1 2021-12-15 16:07:09 -05:00
README.md Fix various typos and grammar nits 2022-01-21 21:43:43 -06:00

Dioxus LiveView

Enabling server-rendered and hybrid applications with incredibly low latency (<1ms).

#[async_std::main]
async fn main() -> tide::Result<()> {
    let liveview_pool = dioxus::liveview::pool::default();
    let mut app = tide::new();

    // serve the liveview client
    app.at("/").get(dioxus::liveview::liveview_frontend);

    // and then connect the client to the backend
    app.at("/app").get(|req| dioxus::liveview::launch(App, Props { req }))

    app.listen("127.0.0.1:8080").await?;

    Ok(())
}

Dioxus LiveView runs your Dioxus apps on the server

use soyuz::prelude::*;

#[tokio::main]
async fn main() {
    let mut app = soyuz::new();
    app.at("/app").get(websocket(handler));
    app.listen("127.0.0.1:8080").await.unwrap();
}

async fn order_shoes(mut req: WebsocketRequest) -> Response {
    let stream = req.upgrade();
    dioxus::liveview::launch(App, stream).await;
}

fn App(cx: Scope) -> Element {
    let mut count = use_state(&cx, || 0);
    cx.render(rsx!(
        button { onclick: move |_| count += 1, "Incr" }
        button { onclick: move |_| count -= 1, "Decr" }
    ))
}