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

Getting started Kotlin Multiplatform

Getting started Kotlin Multiplatform

Mohit Sharma

February 19, 2022
Tweet

More Decks by Mohit Sharma

Other Decks in Programming

Transcript

  1. Agenda • Intro • Why KMM ? • Basics of

    KMM • Getting Started • Code • Q & A
  2. Hi, I’m Mohit 👋 codeWithMohit MongoDB, Ireland Realm Developer Advocate

    Dubizzle (Olx), Dubai Mobile Evangelist ToTheNew, New Delhi Lead Mobile Developer
  3. - Open Source Mobile Database - Object-oriented database - Build

    for Offline first application - Out of the box data sync - Function, tiggers, Auth, GraphQL
  4. // Common expect fun randomUUID(): String // Android import java.util.*

    actual fun randomUUID() = UUID.randomUUID().toString() // iOS import platform.Foundation.NSUUID actual fun randomUUID(): String = NSUUID().UUIDString()
  5. // Common expect class Platform() { val platform: String }

    // Android actual class Platform actual constructor() { actual val platform: String = "Android ${android.os.Build.VERSION.SDK_INT}" } // iOS import platform.UIKit.UIDevice actual class Platform actual constructor() { actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion }
  6. suspend fun loadMovies():MoviesList? { val url = MY_URL return networkService.loadData<MoviesList>(url)

    } func getMovies() { self.networkService?.loadMovies {(movies, error) in //... } }
  7. Library Support - Ktor - Kotlinx Serialisation - Realm -

    AAkria/Kotlin-Multiplatform -Libraries
  8. Advantages Disadvantages - Separation on concern - Kotlin - No

    bridges! - Low commitment - Learn curve is small - API in Alpha - Gradle configuration is a pain