diff --git a/packages/core/src/scopes.rs b/packages/core/src/scopes.rs index 00c3024bf..c6ba5b66a 100644 --- a/packages/core/src/scopes.rs +++ b/packages/core/src/scopes.rs @@ -10,7 +10,7 @@ use std::{ collections::HashMap, future::Future, pin::Pin, - rc::Rc, + rc::Rc, sync::Arc, }; /// for traceability, we use the raw fn pointer to identify the function @@ -582,9 +582,9 @@ impl ScopeState { /// Create a subscription that schedules a future render for the reference component /// /// ## Notice: you should prefer using prepare_update and get_scope_id - pub fn schedule_update(&self) -> Rc { + pub fn schedule_update(&self) -> Arc { let (chan, id) = (self.tasks.sender.clone(), self.scope_id()); - Rc::new(move || { + Arc::new(move || { let _ = chan.unbounded_send(SchedulerMsg::Immediate(id)); }) } @@ -594,9 +594,9 @@ impl ScopeState { /// A component's ScopeId can be obtained from `use_hook` or the [`ScopeState::scope_id`] method. /// /// This method should be used when you want to schedule an update for a component - pub fn schedule_update_any(&self) -> Rc { + pub fn schedule_update_any(&self) -> Arc { let chan = self.tasks.sender.clone(); - Rc::new(move |id| { + Arc::new(move |id| { let _ = chan.unbounded_send(SchedulerMsg::Immediate(id)); }) } diff --git a/packages/fermi/src/root.rs b/packages/fermi/src/root.rs index 5c07083be..d80b176dc 100644 --- a/packages/fermi/src/root.rs +++ b/packages/fermi/src/root.rs @@ -1,4 +1,4 @@ -use std::{any::Any, cell::RefCell, collections::HashMap, rc::Rc}; +use std::{any::Any, cell::RefCell, collections::HashMap, rc::Rc, sync::Arc}; use dioxus_core::ScopeId; use im_rc::HashSet; @@ -9,7 +9,7 @@ pub type AtomId = *const (); pub struct AtomRoot { pub atoms: RefCell>, - pub update_any: Rc, + pub update_any: Arc, } pub struct Slot { @@ -18,7 +18,7 @@ pub struct Slot { } impl AtomRoot { - pub fn new(update_any: Rc) -> Self { + pub fn new(update_any: Arc) -> Self { Self { update_any, atoms: RefCell::new(HashMap::new()), diff --git a/packages/hooks/src/use_shared_state.rs b/packages/hooks/src/use_shared_state.rs index a05e99d7d..2f3f201a2 100644 --- a/packages/hooks/src/use_shared_state.rs +++ b/packages/hooks/src/use_shared_state.rs @@ -2,7 +2,7 @@ use dioxus_core::{ScopeId, ScopeState}; use std::{ cell::{Cell, Ref, RefCell, RefMut}, collections::HashSet, - rc::Rc, + rc::Rc, sync::Arc, }; type ProvidedState = RefCell>; @@ -10,7 +10,7 @@ type ProvidedState = RefCell>; // Tracks all the subscribers to a shared State pub struct ProvidedStateInner { value: Rc>, - notify_any: Rc, + notify_any: Arc, consumers: HashSet, } diff --git a/packages/hooks/src/usefuture.rs b/packages/hooks/src/usefuture.rs index 58f350124..e1d57eec5 100644 --- a/packages/hooks/src/usefuture.rs +++ b/packages/hooks/src/usefuture.rs @@ -1,5 +1,5 @@ use dioxus_core::{ScopeState, TaskId}; -use std::{cell::Cell, future::Future, rc::Rc}; +use std::{cell::Cell, future::Future, rc::Rc, sync::Arc}; pub fn use_future<'a, T: 'static, F: Future + 'static>( cx: &'a ScopeState, @@ -43,7 +43,7 @@ pub fn use_future<'a, T: 'static, F: Future + 'static>( } pub struct UseFuture { - update: Rc, + update: Arc, needs_regen: Cell, value: Option, slot: Rc>>, diff --git a/packages/hooks/src/useref.rs b/packages/hooks/src/useref.rs index c2537e079..7441f85b0 100644 --- a/packages/hooks/src/useref.rs +++ b/packages/hooks/src/useref.rs @@ -1,7 +1,7 @@ use dioxus_core::ScopeState; use std::{ cell::{Ref, RefCell, RefMut}, - rc::Rc, + rc::Rc, sync::Arc, }; /// `use_ref` is a key foundational hook for storing state in Dioxus. @@ -121,7 +121,7 @@ pub fn use_ref<'a, T: 'static>( /// A type created by the [`use_ref`] hook. See its documentation for more details. pub struct UseRef { - update: Rc, + update: Arc, value: Rc>, } diff --git a/packages/hooks/src/usestate.rs b/packages/hooks/src/usestate.rs index 7e8892be9..e0d40b993 100644 --- a/packages/hooks/src/usestate.rs +++ b/packages/hooks/src/usestate.rs @@ -4,7 +4,7 @@ use dioxus_core::prelude::*; use std::{ cell::{RefCell, RefMut}, fmt::{Debug, Display}, - rc::Rc, + rc::Rc, sync::Arc, }; /// Store state between component renders. @@ -69,7 +69,7 @@ pub fn use_state<'a, T: 'static>( pub struct UseState { pub(crate) current_val: Rc, - pub(crate) update_callback: Rc, + pub(crate) update_callback: Arc, pub(crate) setter: Rc, pub(crate) slot: Rc>>, } diff --git a/packages/router/src/service.rs b/packages/router/src/service.rs index a4ab4dc0d..5487bcc24 100644 --- a/packages/router/src/service.rs +++ b/packages/router/src/service.rs @@ -2,7 +2,7 @@ use gloo::history::{BrowserHistory, History, HistoryListener, Location}; use std::{ cell::{Cell, Ref, RefCell}, collections::{HashMap, HashSet}, - rc::Rc, + rc::Rc, sync::Arc, }; use dioxus_core::ScopeId; @@ -10,7 +10,7 @@ use dioxus_core::ScopeId; use crate::platform::RouterProvider; pub struct RouterService { - pub(crate) regen_route: Rc, + pub(crate) regen_route: Arc, pub(crate) pending_events: Rc>>, slots: Rc>>, onchange_listeners: Rc>>, @@ -42,7 +42,7 @@ enum RouteSlot { } impl RouterService { - pub fn new(regen_route: Rc, root_scope: ScopeId) -> Self { + pub fn new(regen_route: Arc, root_scope: ScopeId) -> Self { let history = BrowserHistory::default(); let location = history.location(); let path = location.path();