@@ -374,47 +374,16 @@ impl Effect<SyncStorage> {
374374 /// This spawns a task that can be run on any thread. For an effect that will be spawned on
375375 /// the current thread, use [`new`](Effect::new).
376376 pub fn new_sync < T , M > (
377- mut fun : impl EffectFunction < T , M > + Send + Sync + ' static ,
377+ fun : impl EffectFunction < T , M > + Send + Sync + ' static ,
378378 ) -> Self
379379 where
380380 T : Send + Sync + ' static ,
381381 {
382- let inner = cfg ! ( feature = "effects" ) . then ( || {
383- let ( mut rx, owner, inner) = effect_base ( ) ;
384- let mut first_run = true ;
385- let value = Arc :: new ( RwLock :: new ( None :: < T > ) ) ;
386-
387- crate :: spawn ( {
388- let value = Arc :: clone ( & value) ;
389- let subscriber = inner. to_any_subscriber ( ) ;
390-
391- async move {
392- while rx. next ( ) . await . is_some ( ) {
393- if !owner. paused ( )
394- && ( subscriber. with_observer ( || {
395- subscriber. update_if_necessary ( )
396- } ) || first_run)
397- {
398- first_run = false ;
399- subscriber. clear_sources ( & subscriber) ;
400-
401- let old_value =
402- mem:: take ( & mut * value. write ( ) . or_poisoned ( ) ) ;
403- let new_value = owner. with_cleanup ( || {
404- subscriber. with_observer ( || {
405- run_in_effect_scope ( || fun. run ( old_value) )
406- } )
407- } ) ;
408- * value. write ( ) . or_poisoned ( ) = Some ( new_value) ;
409- }
410- }
411- }
412- } ) ;
413-
414- ArenaItem :: new_with_storage ( Some ( inner) )
415- } ) ;
382+ if !cfg ! ( feature = "effects" ) {
383+ return Self { inner : None } ;
384+ }
416385
417- Self { inner }
386+ Self :: new_isomorphic ( fun )
418387 }
419388
420389 /// Creates a new effect, which runs once on the next “tick”, and then runs again when reactive values
0 commit comments