Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ lily Public

Lily is a tiny framework for rapid and easy development of live/real-time web applications in Scala.

Notifications You must be signed in to change notification settings

otobrglez/lily

Repository files navigation

The Lily Framework

Lily is a lightweight framework for the rapid and easy development of live, real-time web applications in Scala.

Lily is built around and integrates flawlessly with ZIO HTTP and ZIO Streams.

The framework offloads the rendering heavy lifting to the server side (DOM) and communicates with the frontend via DOM diffing and binary WebSockets (CBOR).

It's a work in progress, so please expect changes. Please take a look at example apps for some inspiration.

Example app

object CounterExample extends LiveView[Any, Int]:
  def state = ZStream.fromZIO(ZIO.succeed(0))

  def on(s: Int) =
    case on("increment" -> _) => ZIO.succeed(s + 1)
    case on("decrement" -> _) => ZIO.succeed(s - 1)
    case _                    => ZIO.succeed(s)

  def render(n: Int, path: Path): Task[Html] = ZIO.succeed:
    Examples.layout(Some("Simple Counter Example"), Some(path))(
      h1("Lily - Counter example"),
      div(p(s"Counter is now: $n")),
      div(p(s"Plus two is ${n + 2}")),
      div(p(s"Some math: ${n * 1.2 * Math.PI}")),
      div(
        button("Increment").on("click" -> "increment"),
        button("Decrement").on("click" -> "decrement")
      )
    )


// Add to your ZIO HTTP routes via:

private val routes =
  Routes(
    Method.GET / Root -> handler(Response.text("Hello, World!"))
  )
    ++ LiveView.route(Path.empty / "counter-v2", examples.CounterExample)

- Oto

Development

  • Use devenv to get Java JDK. Check devenv.nix for more information.
  • Lily can be interactively developed with the help of sbt-revolver with:
sbt ~apps/reStart
sbt ~core/test

About

Lily is a tiny framework for rapid and easy development of live/real-time web applications in Scala.

Resources

Stars

Watchers

Forks