diff --git a/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala b/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala index 55d0d1c..68e8343 100644 --- a/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala +++ b/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala @@ -40,7 +40,7 @@ ): Modifier[HtmlElement] = onMountCallback(ctx => val _ = effects.foreach { effect => - val _ = Unsafe.unsafe { implicit unsafe => + val _ = Unsafe.unsafely { runtime.unsafe .runToFuture( handler.handle(effect).either.runForeach { diff --git a/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala b/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala index 55d0d1c..68e8343 100644 --- a/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala +++ b/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala @@ -40,7 +40,7 @@ ): Modifier[HtmlElement] = onMountCallback(ctx => val _ = effects.foreach { effect => - val _ = Unsafe.unsafe { implicit unsafe => + val _ = Unsafe.unsafely { runtime.unsafe .runToFuture( handler.handle(effect).either.runForeach { diff --git a/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala b/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala index 25b57d8..cef1b34 100644 --- a/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala +++ b/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala @@ -2,14 +2,16 @@ import zio.* import works.iterative.core.UserMessage +import works.iterative.core.MessageCatalogue -class ConsoleNotificationService extends UserNotificationService: +class ConsoleNotificationService(messages: MessageCatalogue) + extends UserNotificationService: override def notify( level: UserNotificationService.Level, msg: UserMessage ): UIO[Unit] = - ZIO.succeed(org.scalajs.dom.console.log(s"[$level] $msg")) + ZIO.succeed(org.scalajs.dom.console.log(s"[$level] ${messages(msg)}")) object ConsoleNotificationService: - val layer: ULayer[UserNotificationService] = - ZLayer.succeed(ConsoleNotificationService()) + val layer: URLayer[MessageCatalogue, UserNotificationService] = + ZLayer.derive[ConsoleNotificationService] diff --git a/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala b/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala index 55d0d1c..68e8343 100644 --- a/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala +++ b/ui/js/src/main/scala/works/iterative/ui/components/laminar/EffectHandler.scala @@ -40,7 +40,7 @@ ): Modifier[HtmlElement] = onMountCallback(ctx => val _ = effects.foreach { effect => - val _ = Unsafe.unsafe { implicit unsafe => + val _ = Unsafe.unsafely { runtime.unsafe .runToFuture( handler.handle(effect).either.runForeach { diff --git a/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala b/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala index 25b57d8..cef1b34 100644 --- a/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala +++ b/ui/js/src/main/scala/works/iterative/ui/services/ConsoleNotificationService.scala @@ -2,14 +2,16 @@ import zio.* import works.iterative.core.UserMessage +import works.iterative.core.MessageCatalogue -class ConsoleNotificationService extends UserNotificationService: +class ConsoleNotificationService(messages: MessageCatalogue) + extends UserNotificationService: override def notify( level: UserNotificationService.Level, msg: UserMessage ): UIO[Unit] = - ZIO.succeed(org.scalajs.dom.console.log(s"[$level] $msg")) + ZIO.succeed(org.scalajs.dom.console.log(s"[$level] ${messages(msg)}")) object ConsoleNotificationService: - val layer: ULayer[UserNotificationService] = - ZLayer.succeed(ConsoleNotificationService()) + val layer: URLayer[MessageCatalogue, UserNotificationService] = + ZLayer.derive[ConsoleNotificationService] diff --git a/ui/shared/src/main/scala/works/iterative/ui/ZIOEffectHandler.scala b/ui/shared/src/main/scala/works/iterative/ui/ZIOEffectHandler.scala index a3ea176..e242403 100644 --- a/ui/shared/src/main/scala/works/iterative/ui/ZIOEffectHandler.scala +++ b/ui/shared/src/main/scala/works/iterative/ui/ZIOEffectHandler.scala @@ -9,14 +9,16 @@ def fromZIO( zio: ZIO[Env, Throwable, Action] ): ZStream[Env, Throwable, Action] = - ZStream.fromZIO(zio) + ZStream.fromZIO(zio.resurrect) def fromZIOOption( zio: ZIO[Env, Throwable, Option[Action]] ): ZStream[Env, Throwable, Action] = - ZStream.fromZIO(zio).collect { case Some(a) => a } + ZStream.fromZIO(zio.resurrect).collect { case Some(a) => a } def fromZIOUnit( zio: ZIO[Env, Throwable, Unit] ): ZStream[Env, Throwable, Action] = - ZStream.fromZIO(zio.as(Option.empty[Action])).collect { case Some(a) => a } + ZStream.fromZIO(zio.as(Option.empty[Action]).resurrect).collect { + case Some(a) => a + }