소스 검색

feat: add send + sync for safety

Ilya Maximov 3 년 전
부모
커밋
144e0bd91f
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  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
     ///
     /// ## 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());
         Arc::new(move || {
             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.
     ///
     /// 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();
         Arc::new(move |id| {
             let _ = chan.unbounded_send(SchedulerMsg::Immediate(id));