Skip to content
MVU for Kotlin Multiplatform
Branch: master
Clone or download
Michael Pardo
Michael Pardo Add Analytics script.
Latest commit 5b5c721 Jun 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.buildscript Change pardo references to oolong-kt. (#23) Mar 20, 2019
.github/ISSUE_TEMPLATE Update issue templates (#21) Mar 20, 2019
buildSrc Require non-null type parameters. May 19, 2019
docs Add Analytics script. Jun 14, 2019
gradle Use Docsify. May 20, 2019
oolong fix(runtime): Remove default arguments for Runtime constructor. Jun 9, 2019
samples docs(samples): Fix insecure js imports. Jun 7, 2019
.gitignore docs(samples): Add samples to docs. Jun 7, 2019
.travis.yml Api cleanup (#50) Apr 26, 2019
LICENSE.md Create LICENSE.md Aug 1, 2018
README.md Update README.md May 31, 2019
build.gradle.kts Clean deletes dokka dir and build depends on dokka. May 21, 2019
gradle.properties
gradlew Fix refactorings. Feb 3, 2019
gradlew.bat Fix refactorings. Feb 3, 2019
settings.gradle.kts Extract MainLoopDispatcher to sample utils. May 19, 2019

README.md

Oolong

Build Status Maven Central Sonatype Nexus (Snapshots) License Gitter chat

Oolong is an Elm inspired Model-View-Update (MVU) implementation for Kotiln multiplatform. As the name implies, three core concepts comprise the foundation of this architecture:

  • Model - a type to represent the program state

  • View - a function to map the state to view properties

  • Update - a function to update the state

By applying this simple pattern you can create composable, testable programs that can run on any platform. Oolong enables a common codebase for all platforms by using a Render function which is implemented by each frontend.

Get started with Oolong by reading the official guide.

Example

The following is a simple counter example in which the count can be incremented or decremented.

object Counter {

    data class Model(
        val count: Int = 0
    )

    sealed class Msg {
        object Increment : Msg()
        object Decrement : Msg()
    }

    class Props(
        val count: Int,
        val increment: () -> Msg,
        val decrement: () -> Msg
    )

    val init: Init<Model, Msg> = { 
        Model() to none()
    }

    val update: Update<Model, Msg> = { msg, model ->
        when (msg) {
            Msg.Increment -> model.copy(count = model.count + 1)
            Msg.Decrement -> model.copy(count = model.count - 1)
        } to none()
    }

    val view: View<Model, Props> = { model ->
        Props(
            model.count,
            { Msg.Increment },
            { Msg.Decrement }
        )
    }

}

Samples

More examples can be found in the samples directory.

Documentation

Further reading can be found in the official guide and documentation.

Download

dependencies {
    implementation("org.oolong-kt:oolong:2.0.0")
}
You can’t perform that action at this time.