mirror of
https://github.com/phfroidmont/scalive.git
synced 2025-12-25 05:26:59 +01:00
Remove the need to wrap every model in ZIO
This commit is contained in:
parent
1da129f855
commit
c19086ef32
6 changed files with 24 additions and 30 deletions
|
|
@ -8,10 +8,10 @@ import zio.stream.ZStream
|
|||
import TestView.*
|
||||
class TestView extends LiveView[Msg, Model]:
|
||||
|
||||
def init = ZIO.succeed(Model())
|
||||
def init = Model()
|
||||
|
||||
def update(model: Model) =
|
||||
case Msg.UpdateModel(f) => ZIO.succeed(f(model))
|
||||
case Msg.UpdateModel(f) => f(model)
|
||||
|
||||
def view(model: Dyn[Model]) =
|
||||
div(
|
||||
|
|
|
|||
|
|
@ -8,3 +8,5 @@ trait LiveView[Msg, Model]:
|
|||
def update(model: Model): Msg => Task[Model]
|
||||
def view(model: Dyn[Model]): HtmlElement
|
||||
def subscriptions(model: Model): ZStream[Any, Nothing, Msg]
|
||||
|
||||
given [T]: Conversion[T, Task[T]] = ZIO.succeed(_)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue