Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Musings on Kotlin Multiplatform Mobile

Annyce D.
January 28, 2021

Musings on Kotlin Multiplatform Mobile

In this talk, I share my initial thoughts on Kotlin Multiplatform Mobile (KMM). I walk through how I started on this journey. I also compare my experience with KMM to that of working with Flutter. Flutter is another cross-platform solution that I've worked with in the past.

Annyce D.

January 28, 2021
Tweet

More Decks by Annyce D.

Other Decks in Technology

Transcript

  1. Annyce Davis - @brwngrldev
    Musings on Kotlin Multiplatform Mobile
    January 2021

    View full-size slide

  2. My journey
    How I got started with KMM
    1. Attended an AMA

    2. Started following devs on Twitter

    3. Pulled down a sample app

    4. Wrote a sample app

    5. Read documentation

    6. Watched videos on YouTube
    @brwngrldev

    View full-size slide

  3. After the AMA
    I finally started to get it!
    K
    otlin
    K
    otlin/N
    ative
    K
    M
    P
    K
    M
    M
    @brwngrldev

    View full-size slide

  4. Twitter friends
    What are folks up to with KMM
    @brwngrldev

    View full-size slide

  5. Todo App
    Created with KMM plugin
    @brwngrldev

    View full-size slide

  6. • Ktor

    • Koin

    • Kermit

    • SwiftUI

    • Jetpack Components
    Developed with:
    @brwngrldev

    View full-size slide

  7. Architecture
    Created with KMM plugin
    Data model API
    Repository Dependency Injection
    Shared code
    Todo App
    iOS Project Android Project
    @brwngrldev

    View full-size slide

  8. Data model
    Kotlinx Serialization
    @Serializable
    data class Todo(
    @SerialName("id")
    val id: Int,
    @SerialName("title")
    val title: String,
    @SerialName("completed")
    val completed: Boolean
    )
    @brwngrldev

    View full-size slide

  9. API
    Ktor
    private val httpClient = HttpClient {
    install(JsonFeature) {
    val json = Json { ignoreUnknownKeys = true }
    serializer = KotlinxSerializer(json)
    }
    }
    override suspend fun getAllTodos(): List {
    return httpClient.get(ENDPOINT)
    }
    @brwngrldev

    View full-size slide

  10. Repository
    Koin and Kermit
    private val api: TodosApi by inject()
    private val logger: Kermit by inject()
    private val todos: MutableList = mutableListOf()
    @brwngrldev

    View full-size slide

  11. Repository
    Koin and Kermit
    private val api: TodosApi by inject()
    private val logger: Kermit by inject()
    private val todos: MutableList = mutableListOf()
    @Throws(Exception::class)
    suspend fun getAllTodos(forceReload: Boolean): List {
    logger.i{ "loading todos" }
    return if (todos.isNotEmpty() && !forceReload) {
    todos
    } else {
    api.getAllTodos().also {
    todos.clear()
    todos.addAll(it)
    }
    }
    }
    @brwngrldev

    View full-size slide

  12. Wasn’t all roses
    • Struggled with using Koin in the
    iOS app

    • Couldn’t figure out how to use
    the Kermit logger in the iOS app

    • Android Studio would misbehave
    often

    • I didn’t know any SwiftUI
    Challenges

    View full-size slide

  13. How does KMM compare?
    @brwngrldev

    View full-size slide

  14. Comparison
    Standard/KMM/Flutter
    Standard KMM Flutter
    Language
    Learning Curve
    Maturity
    Platform UI
    Community
    @brwngrldev

    View full-size slide

  15. Comparison
    Standard/KMM/Flutter
    Standard KMM Flutter
    Language ⭐⭐ ⭐⭐ ⭐
    Learning Curve
    Maturity
    Platform UI
    Community
    @brwngrldev

    View full-size slide

  16. Comparison
    Standard/KMM/Flutter
    Standard KMM Flutter
    Language ⭐⭐ ⭐⭐ ⭐
    Learning Curve ⭐⭐ ⭐⭐ ⭐
    Maturity
    Platform UI
    Community
    @brwngrldev

    View full-size slide

  17. Comparison
    Standard/KMM/Flutter
    Standard KMM Flutter
    Language ⭐⭐ ⭐⭐ ⭐
    Learning Curve ⭐⭐ ⭐⭐ ⭐
    Maturity ⭐⭐ ⭐
    Platform UI
    Community
    @brwngrldev

    View full-size slide

  18. Comparison
    Standard/KMM/Flutter
    Standard KMM Flutter
    Language ⭐⭐ ⭐⭐ ⭐
    Learning Curve ⭐⭐ ⭐⭐ ⭐
    Maturity ⭐⭐ ⭐
    Platform UI ⭐⭐ ⭐⭐ ⭐
    Community
    @brwngrldev

    View full-size slide

  19. Comparison
    Standard/KMM/Flutter
    Standard KMM Flutter
    Language ⭐⭐ ⭐⭐ ⭐
    Learning Curve ⭐⭐ ⭐⭐ ⭐
    Maturity ⭐⭐ ⭐
    Platform UI ⭐⭐ ⭐⭐ ⭐
    Community ⭐⭐
    @brwngrldev

    View full-size slide

  20. Community
    @brwngrldev

    View full-size slide

  21. Mascot
    KroN Kira the Nightingale
    Meant for illustration purposes
    @brwngrldev

    View full-size slide

  22. Libraries
    Official listing from JetBrains
    https://github.com/AAkira/Kotlin-Multiplatform-Libraries
    @brwngrldev

    View full-size slide

  23. Video tutorials
    (see Boring Flutter show)
    @brwngrldev

    View full-size slide

  24. Recommendations
    How to get more folks into KMM
    • Mascot (Kron or Kira)

    • Listing of available libraries

    • Social media tips (Multiplatform Mondays)

    • YouTube content from a variety of creators

    • More codelabs

    • Partner with existing groups of iOS and Kotlin influencers

    • Weekly office hours
    @brwngrldev

    View full-size slide

  25. Thanks!
    @brwngrldev

    View full-size slide