Added frontend status of websocket connectoin
This commit is contained in:
parent
067a0860ab
commit
94cf11e1c2
@ -1,15 +1,17 @@
|
||||
use leptos::*;
|
||||
use leptos_router::*;
|
||||
use leptos_use::core::ConnectionReadyState;
|
||||
|
||||
/// Renders the home page of your application.
|
||||
#[component]
|
||||
pub fn Header() -> impl IntoView {
|
||||
let ready_state = use_context::<Signal<ConnectionReadyState>>();
|
||||
// Creates a reactive value to update the button
|
||||
view! {
|
||||
<header>
|
||||
<div class="header-container">
|
||||
<A href="/">"WRB Timings"</A>
|
||||
<div>Connection: <span>???</span></div>
|
||||
<div>"Connection: " { move || format!("{}", ready_state.unwrap().get()) }</div>
|
||||
</div>
|
||||
</header>
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::util::surrealdb::schemas;
|
||||
use leptos::{ev::keydown, *};
|
||||
use leptos_router::{ActionForm, FromFormData};
|
||||
use leptos_use::*;
|
||||
use strsim::normalized_damerau_levenshtein;
|
||||
use web_sys::ScrollIntoViewOptions;
|
||||
|
@ -11,6 +11,8 @@ pub fn init_websocket() {
|
||||
..
|
||||
} = use_websocket("ws://localhost:3000/ws");
|
||||
|
||||
provide_context(ready_state);
|
||||
|
||||
create_effect(move |prev_value| {
|
||||
let msg = message.get();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user