refactor: remove once_cell dependency and use std::sync equivalents (#4185)

This commit is contained in:
Falk Woldmann authored and GitHub committed 2025-05-25 16:09:56 +01:00
1 parent 1d954c2f6f
commit 3c3256ec02
22 files changed
+22 -47

No files matched your search

+2 -2
View File
@@ -6,10 +6,10 @@ use std::cell::RefCell;
use dioxus_lib::{document::*, prelude::*};
use dioxus_ssr::Renderer;
use once_cell::sync::Lazy;
use parking_lot::RwLock;
use std::sync::LazyLock;
static RENDERER: Lazy<RwLock<Renderer>> = Lazy::new(|| RwLock::new(Renderer::new()));
static RENDERER: LazyLock<RwLock<Renderer>> = LazyLock::new(|| RwLock::new(Renderer::new()));
/// Reset the static renderer to a fresh state, clearing its cache.
pub(crate) fn reset_renderer() {
+2 -2
View File
@@ -331,7 +331,7 @@ pub(crate) fn add_server_context(
pub struct RenderHandleState {
config: ServeConfig,
build_virtual_dom: Arc<dyn Fn() -> VirtualDom + Send + Sync>,
ssr_state: once_cell::sync::OnceCell<SSRState>,
ssr_state: std::sync::OnceLock<SSRState>,
}
impl RenderHandleState {
@@ -364,7 +364,7 @@ impl RenderHandleState {
/// Set the [`SSRState`] for this [`RenderHandleState`]. Sharing a [`SSRState`] between multiple [`RenderHandleState`]s is more efficient than creating a new [`SSRState`] for each [`RenderHandleState`].
pub fn with_ssr_state(mut self, ssr_state: SSRState) -> Self {
self.ssr_state = once_cell::sync::OnceCell::new();
self.ssr_state = std::sync::OnceLock::new();
if self.ssr_state.set(ssr_state).is_err() {
panic!("SSRState already set");
}