Basic zio-http based live router

This commit is contained in:
Paul-Henri Froidmont 2025-08-20 01:31:10 +02:00
parent cff02a4c96
commit 385436f8fe
Signed by: phfroidmont
GPG key ID: BE948AFD7E7873BE
6 changed files with 80 additions and 96 deletions

View file

@ -11,7 +11,7 @@ def main =
)
val s = Socket(TestView(initModel))
println("Init")
println(s.renderHtml)
println(s.renderHtml())
s.syncClient
s.syncClient
@ -34,7 +34,7 @@ def main =
)
)
s.syncClient
println(s.renderHtml)
println(s.renderHtml())
println("Add one")
s.receiveCommand(
@ -50,7 +50,7 @@ def main =
)
)
s.syncClient
println(s.renderHtml)
println(s.renderHtml())
println("Remove first")
s.receiveCommand(
@ -65,7 +65,7 @@ def main =
)
)
s.syncClient
println(s.renderHtml)
println(s.renderHtml())
println("Remove all")
s.receiveCommand(
@ -79,5 +79,5 @@ def main =
)
s.syncClient
s.syncClient
println(s.renderHtml)
println(s.renderHtml())
end main

View file

@ -12,9 +12,9 @@ final case class Socket[Cmd](lv: LiveView[Cmd]):
def receiveCommand(cmd: Cmd): Unit =
lv.handleCommand(cmd)
def renderHtml: String =
def renderHtml(rootLayout: HtmlElement => HtmlElement = identity): String =
lv.el.syncAll()
HtmlBuilder.build(lv.el, isRoot = true)
HtmlBuilder.build(rootLayout(lv.el))
def syncClient: Unit =
lv.el.syncAll()