@@ -79,36 +79,16 @@ impl<S> Dispose for ImmediateEffect<S> {
7979
8080impl ImmediateEffect < LocalStorage > {
8181 /// Creates a new effect, which runs immediately, then again as soon as any tracked signal changes.
82- pub fn new < T , M > ( mut fun : impl EffectFunction < T , M > + ' static ) -> Self
82+ pub fn new < T , M > (
83+ fun : impl EffectFunction < T , M > + Send + Sync + ' static ,
84+ ) -> Self
8385 where
8486 T : Send + Sync + ' static ,
8587 {
8688 if !cfg ! ( feature = "effects" ) {
8789 return Self { inner : None } ;
8890 }
8991
90- let fun = {
91- let thread_id = std:: thread:: current ( ) . id ( ) ;
92-
93- /// A wrapper type that is always `Send` and `Sync`.
94- struct UnsafeSendSync < T > ( T ) ;
95- unsafe impl < T > Send for UnsafeSendSync < T > { }
96- unsafe impl < T > Sync for UnsafeSendSync < T > { }
97- impl < F , T , M > EffectFunction < T , M > for UnsafeSendSync < F >
98- where
99- F : EffectFunction < T , M > + ' static ,
100- {
101- fn run ( & mut self , p : Option < T > ) -> T {
102- self . 0 . run ( p)
103- }
104- }
105-
106- UnsafeSendSync ( move |v| {
107- assert_eq ! ( thread_id, std:: thread:: current( ) . id( ) ) ;
108- fun. run ( v)
109- } )
110- } ;
111-
11292 let inner = inner:: EffectInner :: new ( fun) ;
11393
11494 inner. update_if_necessary ( ) ;
0 commit comments