| Crates.io | dioxus-websocket-hooks |
| lib.rs | dioxus-websocket-hooks |
| version | 0.0.2 |
| created_at | 2022-01-10 07:51:44.147959+00 |
| updated_at | 2022-01-15 12:20:58.547751+00 |
| description | Dioxus hooks for websocket connections |
| homepage | |
| repository | https://github.com/FruitieX/dioxus-websocket-hooks |
| max_upload_size | |
| id | 511265 |
| size | 39,258 |
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" }
))
}
See cargo examples
Samples make use of fermi for state management.