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