Bläddra i källkod

feat: add send + sync for safety

Ilya Maximov 3 år sedan
förälder
incheckning
144e0bd91f
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      packages/core/src/scopes.rs

+ 2 - 2
packages/core/src/scopes.rs

@@ -588,7 +588,7 @@ impl ScopeState {
     /// Create a subscription that schedules a future render for the reference component
     /// Create a subscription that schedules a future render for the reference component
     ///
     ///
     /// ## Notice: you should prefer using prepare_update and get_scope_id
     /// ## Notice: you should prefer using prepare_update and get_scope_id
-    pub fn schedule_update(&self) -> Arc<dyn Fn() + 'static> {
+    pub fn schedule_update(&self) -> Arc<dyn Fn() + Send + Sync + 'static> {
         let (chan, id) = (self.tasks.sender.clone(), self.scope_id());
         let (chan, id) = (self.tasks.sender.clone(), self.scope_id());
         Arc::new(move || {
         Arc::new(move || {
             let _ = chan.unbounded_send(SchedulerMsg::Immediate(id));
             let _ = chan.unbounded_send(SchedulerMsg::Immediate(id));
@@ -600,7 +600,7 @@ impl ScopeState {
     /// A component's ScopeId can be obtained from `use_hook` or the [`ScopeState::scope_id`] method.
     /// 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
     /// This method should be used when you want to schedule an update for a component
-    pub fn schedule_update_any(&self) -> Arc<dyn Fn(ScopeId)> {
+    pub fn schedule_update_any(&self) -> Arc<dyn Fn(ScopeId) + Send + Sync> {
         let chan = self.tasks.sender.clone();
         let chan = self.tasks.sender.clone();
         Arc::new(move |id| {
         Arc::new(move |id| {
             let _ = chan.unbounded_send(SchedulerMsg::Immediate(id));
             let _ = chan.unbounded_send(SchedulerMsg::Immediate(id));