Skip to content

Commit 6adbb22

Browse files
committed
Run IO as synchronously as possible
Closes #1010
1 parent 9c394b9 commit 6adbb22

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

coreExtCatsEffect/src/main/scala/japgolly/scalajs/react/util/EffectCatsEffect.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ object EffectCatsEffect {
9999
f => () => fa.unsafeRunAsync(ea => f(ea.toTry)())(runtime())
100100

101101
override def dispatch[A](fa: IO[A]): Unit =
102-
fa.unsafeRunAndForget()(runtime())
102+
fa.syncStep.unsafeRunSync().fold(_.unsafeRunAndForget()(runtime()), _ => ())
103103
}
104104

105105
private lazy val tryUnit: Try[Unit] =

doc/changelog/2.0.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
### Bug fixes
44

55
* Fix infinite loop in functional components with reuse + `Reusability.never` ([#1027](https://github.com/japgolly/scalajs-react/issues/1027))
6+
* When using `cats.effect.IO` as event handlers, it runs as synchronously as possible until it runs into an async step.

0 commit comments

Comments
 (0)