2 releases
0.0.2 | Jan 15, 2022 |
---|---|
0.0.1 | Jan 10, 2022 |
#382 in WebSocket
12KB
144 lines
dioxus-websocket-hooks
Dioxus hooks for websocket connections
use dioxus_websocket_hooks::{use_ws_context, use_ws_context_provider_json};
fn app(cx: Scope) -> Element {
use_ws_context_provider_json(&cx, "wss://echo.websocket.events", move |msg| {
// Handle incoming ws message, e.g. store it in shared state
});
...
}
fn ExampleComponent(cx: Scope) -> Element {
let ws = use_ws_context(&cx);
cx.render(rsx! (
button { onclick: move |_| ws.send_json(&"hello"), "Submit" }
))
}
Examples
See cargo examples
Samples make use of fermi for state management.
Dependencies
~16–28MB
~461K SLoC