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

Realm SDK Kotlin Multiplatform

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Ian Ian
June 16, 2022

Realm SDK Kotlin Multiplatform

Avatar for Ian

Ian

June 16, 2022

More Decks by Ian

Other Decks in Programming

Transcript

  1. It is a platform that allows you to share code

    and build cross-platform mobile applications between Android and iOS
  2. History of Realm • Acquired by MongoDB in 2019 for

    $39 million • Realm established itself as the mobile database platform • MongoDB Realm can now offer capabilities with their Atlas cloud platform
  3. How Kotlin Realm SDK can help you Share code Sharing

    database business logic across both Android and iOS Object Oriented Model We can access objects via our Realm instance Intuitive API We can leverage Kotlin DSLs and NSPredicate style for querying objects Open Source It is open source and accepts community contributions https://github.com/realm/realm-kotlin
  4. Can we use the new memory model? • There is

    a catch! The library is still implemented against the old memory model. • To enable against the new model you will need to follow these instructions —> https://github.com/JetBrains/kotlin/blob/master/kotlin-native/ NEW_MM.md#switch-to-the-new-mm • By default the library requires you to run against the non native coroutines artifact i.e. 1.6.0-native-mt
  5. kotlin.native.binary.memoryModel=experimental kotlin.native.binary.freezing=disabled To run against non mt artifact, add these

    to grade.properties See https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md#unexpected-object- freezing for more details on object freezing
  6. class BeersDb: RealmObject { var id: String = "" var

    name: String = "" var imageUrl: String = "" var abv: Double = 0.0 } Creating a Realm Object
  7. class BeersDb: RealmObject { var id: String = "" var

    name: String = "" var imageUrl: String = "" var abv: Double = 0.0 } Creating a Realm Object
  8. val con fi g = RealmCon fi guration.Builder(schema = setOf(BeersDB::class))

    .build() val realm = Realm.open(con fi g) Creating our Realm instance
  9. val con fi g = RealmCon fi guration.Builder(schema = setOf(BeersDB::class))

    .build() val realm = Realm.open(con fi g) Creating our Realm instance
  10. val con fi g = RealmCon fi guration.Builder(schema = setOf(BeersDB::class))

    .build() val realm = Realm.open(con fi g) Creating our Realm instance