diff --git a/tyrian/js/src/main/scala/tyrian/runtime/Renderer.scala b/tyrian/js/src/main/scala/tyrian/runtime/Renderer.scala index f363423b..200396ea 100644 --- a/tyrian/js/src/main/scala/tyrian/runtime/Renderer.scala +++ b/tyrian/js/src/main/scala/tyrian/runtime/Renderer.scala @@ -4,23 +4,8 @@ import cats.effect.kernel.Async import cats.effect.kernel.Ref import cats.effect.syntax.all.* import snabbdom.VNode -import tyrian.Html -import tyrian.Location -final case class Renderer(vnode: VNode, state: RendererState, lastTriggered: Long): - - def redraw[Model, Msg]( - time: Long, - model: Model, - view: Model => Html[Msg], - onMsg: Msg => Unit, - router: Location => Msg - ): Renderer = - this.copy( - vnode = Rendering.render(vnode, model, view, onMsg, router), // TODO: Replace - state = RendererState.Running, - lastTriggered = time - ) +final case class Renderer(vnode: VNode, state: RendererState, lastTriggered: Long) object Renderer: diff --git a/tyrian/js/src/main/scala/tyrian/runtime/TyrianRuntime.scala b/tyrian/js/src/main/scala/tyrian/runtime/TyrianRuntime.scala index 4b1e2503..f6a6ef6f 100644 --- a/tyrian/js/src/main/scala/tyrian/runtime/TyrianRuntime.scala +++ b/tyrian/js/src/main/scala/tyrian/runtime/TyrianRuntime.scala @@ -65,9 +65,18 @@ object TyrianRuntime: } _ <- runCmd(cmdsAndSubs._1) *> runSub(cmdsAndSubs._2) + m <- model.get + t <- clock.realTime.map(_.toMillis) - _ <- renderer.update(_.redraw(t, m, view, onMsg, router)) + + _ <- renderer.update { r => + r.copy( + vnode = Rendering.render(r.vnode, m, view, onMsg, router), + state = RendererState.Running, + lastTriggered = t + ) + } } yield () }.foreverM