1
2use dioxus::prelude::*;
3
4use crate::{ConnectionState, ForgeClient, ForgeClientConfig};
5
6#[component]
7pub fn ForgeProvider(url: String, children: Element) -> Element {
8 let connection_state = use_context_provider(|| Signal::new(ConnectionState::Disconnected));
9 use_context_provider(|| {
10 let config = ForgeClientConfig::new(url).with_connection_state(connection_state);
11 ForgeClient::new(config)
12 });
13
14 rsx! { {children} }
15}
16
17pub fn use_forge_client() -> ForgeClient {
18 use_context::<ForgeClient>()
19}
20
21pub fn use_connection_state() -> Signal<ConnectionState> {
22 use_context::<Signal<ConnectionState>>()
23}