Skip to content
Snippets Groups Projects
Verified Commit d2c680a4 authored by Hugh Coleman's avatar Hugh Coleman
Browse files

skip render if current view remains unchanged

Rebasing on top of !27.
parent 148cbbdb
Branches
No related tags found
No related merge requests found
...@@ -13,6 +13,9 @@ abstract class WebClientAppInstance[Event, View]( ...@@ -13,6 +13,9 @@ abstract class WebClientAppInstance[Event, View](
sendMessage: ujson.Value => Unit, sendMessage: ujson.Value => Unit,
target: Target target: Target
) extends StateMachineClientAppInstance[Event, View](userId, sendMessage), DOMClientUI[View], PatchableUI: ) extends StateMachineClientAppInstance[Event, View](userId, sendMessage), DOMClientUI[View], PatchableUI:
/** The currently-rendered view, if one exists. */
private var currentView: Option[View] = None
/** Renders a [[View]] received from the server. The method also takes a /** Renders a [[View]] received from the server. The method also takes a
* [[UserId]] to get information on the context and an [[onEvent]] callback * [[UserId]] to get information on the context and an [[onEvent]] callback
* which it uses to send server events when specific actions are triggered on * which it uses to send server events when specific actions are triggered on
...@@ -27,7 +30,9 @@ abstract class WebClientAppInstance[Event, View]( ...@@ -27,7 +30,9 @@ abstract class WebClientAppInstance[Event, View](
protected def render(userId: UserId, view: View): Frag protected def render(userId: UserId, view: View): Frag
override def displayView(view: View): Unit = override def displayView(view: View): Unit =
patchUI(target, render(userId, view)) if Some(view) != currentView then
currentView = Some(view)
patchUI(target, render(userId, view))
override def patchUI(target: dom.Element, fr: Frag): Unit = override def patchUI(target: dom.Element, fr: Frag): Unit =
target.replaceChildren(fr.render) target.replaceChildren(fr.render)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment