Skip to content

y2k/litho-elmish

Repository files navigation

Litho-Elmish

Port of Elm architecture to Kotlin with Litho

Release (https://jitpack.io/#y2k/litho-elmish)

Simple example

Original Elm code: http://elm-lang.org/examples/buttons

object Screen : ElmFunctions<Int, Msg> {

    enum class Msg { Increase, Decrease }

    override fun init(): Pair<Int, Cmd<Msg>> = 0 to Cmd.none()

    override fun update(model: Int, msg: Msg): Pair<Int, Cmd<Msg>> = when (msg) {
        Increase -> (model + 1) to Cmd.none()
        Decrease -> (model - 1) to Cmd.none()
    }

    override fun ContainerBuilder.view(model: Int) {
        text {
            text("-")
            onClick(Decrease)
        }
        text {
            text("$model")
        }
        text {
            text("+")
            onClick(Increase)
        }
    }
}

Example applications

About

Port of Elm architecture to Kotlin with Litho

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages