Cats Effect
Example Links
To use Tyrian with Cats Effect, we need to bring in the tyrian-io library.
ivy"io.indigoengine::tyrian-io::x.y.z" // Mill
libraryDependencies += "io.indigoengine" %%% "tyrian-io" % "x.y.z" // SBT
Then we can bring in the TyrianIOApp
trait to create our application.
@JSExportTopLevel("TyrianApp")
object Counter extends TyrianIOApp[Msg, Model]:
Cmd
s and Sub
s then make use of the IO
type to perform side effects.
def update(model: Model): Msg => (Model, Cmd[IO, Msg]) =
case Msg.Increment => (model + 1, Cmd.None)
case Msg.Decrement => (model - 1, Cmd.None)
case Msg.NoOp => (model, Cmd.None)
def subscriptions(model: Model): Sub[IO, Msg] =
Sub.None