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. 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
  2. After the AMA I finally started to get it! K

    otlin K otlin/N ative K M P K M M @brwngrldev
  3. • Ktor • Koin • Kermit • SwiftUI • Jetpack

    Components Developed with: @brwngrldev
  4. Architecture Created with KMM plugin Data model API Repository Dependency

    Injection Shared code Todo App iOS Project Android Project @brwngrldev
  5. Data model Kotlinx Serialization @Serializable data class Todo( @SerialName("id") val

    id: Int, @SerialName("title") val title: String, @SerialName("completed") val completed: Boolean ) @brwngrldev
  6. API Ktor private val httpClient = HttpClient { install(JsonFeature) {

    val json = Json { ignoreUnknownKeys = true } serializer = KotlinxSerializer(json) } } override suspend fun getAllTodos(): List<Todo> { return httpClient.get(ENDPOINT) } @brwngrldev
  7. Repository Koin and Kermit private val api: TodosApi by inject()

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

    private val logger: Kermit by inject() private val todos: MutableList<Todo> = mutableListOf() @Throws(Exception::class) suspend fun getAllTodos(forceReload: Boolean): List<Todo> { logger.i{ "loading todos" } return if (todos.isNotEmpty() && !forceReload) { todos } else { api.getAllTodos().also { todos.clear() todos.addAll(it) } } } @brwngrldev
  9. 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
  10. Comparison Standard/KMM/Flutter Standard KMM Flutter Language ⭐⭐ ⭐⭐ ⭐ Learning

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

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

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

    Curve ⭐⭐ ⭐⭐ ⭐ Maturity ⭐⭐ ⭐ Platform UI ⭐⭐ ⭐⭐ ⭐ Community ⭐⭐ @brwngrldev
  14. 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